본문 바로가기

반응형

알고리즘

(136)
8958번 OX퀴즈 1234567891011121314151617181920212223242526272829#include #include #include using namespace std; int main() { int n; scanf("%d", &n); while(n--) { char s[81]; scanf("%s", s); int score = 0; int count = 1; for(int i = 0; s[i] != NULL; i++) { if(s[i] == 'O') score += count; if(s[i] == s[i + 1]) { count++; } else count = 1; } printf("%d\n", score); } return 0;}Colored by Color Scriptercs
4344번 평균은 넘겠지 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#include #include using namespace std; int main(){ int numcases; scanf("%d", &numcases); while (numcases--) { int stuNum; scanf("%d", &stuNum); int *stuArr = (int*)calloc(stuNum, sizeof(int)); int sum = 0; for (int i = 0; i
2920번 음계 1234567891011121314151617181920212223242526#include #include using namespace std; #define DESCENDING 0#define ASCENDING 1#define MIXED -1 int main() { int temp, n; scanf("%d", &n); int result; for(int i = 0; i
2908번 상수 12345678910111213141516171819202122232425262728293031323334#include using namespace std; int main(){ int a, b; scanf("%d %d", &a, &b); int newA = 0, newB = 0; while (a >= 1) { newA += a % 10; a /= 10; if (a >= 1) newA *= 10; } while (b >= 1) { newB += b % 10; b /= 10; if (b >= 1) newB *= 10; } if (newA > newB) cout
2675번 문자열 반복 12345678910111213141516171819202122232425262728293031#include #include #include #include using namespace std; int main(){ int numcases; cin >> numcases; while (numcases--) { int n; cin >> n; string s; string result = ""; cin >> s; for(int i = 0; i
2448번 별찍기 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#include #include using namespace std; char arr[3072][6144]; void star(int n, int x, int y) { if(n == 3) { arr[y][x] = '*'; arr[y + 1][x - 1] = '*'; arr[y + 1][x + 1] = '*'; arr[y + 2][x - 2] = '*'; arr[y + 2][x - 1] = '*'; arr[y + 2][x] = '*'; arr[y + 2][x + 1] = '*'; arr[y + 2][x + 2] = '*'; return; } st..
1157번 단어공부 123456789101112131415161718192021222324252627282930313233343536373839404142434445#include #include using namespace std; int main(){ string s; cin >> s; int alpa[27] = { 0, }; for (int i = 0; i
1152번 단어의 개수 1234567891011121314151617181920212223#include #include #include #include #include using namespace std; int main() { string s; getline(cin, s); stringstream ss(s); string str; int count = 0; while(ss >> str) { count++; } cout