본문 바로가기

전체 글

(453)
설탕 배달 #include using namespace std; int main() { int a5, a3; int Num; int i = 0; cin >> Num; a5 = Num / 5; while (1) { if (Num % 5 == 0) { cout
손익분기점 #include using namespace std; int main() { int price[3]; for (int i = 0; i > price[i]; if ((price[2] - price[1])
Vector 이용 #include #include #include using namespace std; class list { struct Num { char name[20]; char phone[20]; }; vector Nums; public: void Registerd() { char InName[20]; cin >> InName; Num *NewNum = new Num; strcpy(NewNum->name, InName); Nums.push_back(NewNum); } void listOut() { for (int i = 0; i
그룹 단어 체커 #include #include using namespace std; int cnt; void Checker(string word) { int len = word.size(); for (int i = 0; i > num; for (int i = 0; i > word; Checker(word); } cout
크로아티아 알파벳 #include #include using namespace std; int main() { int cnt = 0; string word; cin >> word; for (int i = 0; i = 0) { word[i] = '0'; } else if (word[i - 1] == 'z' &&i - 1 >= 0) { if (word[i - 2] == 'd' && i - 2 >= 0) { word[i - 1] = '0'; word[i] = '0'; } else word[i] = '0'; } } else if (word[i..
다이얼 #include #include int main(void) { char str[16] = { 0 }; // 배열 생성 int time[] = { 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10 }; //알파벳에 따른 시간 int res = 0; scanf("%s", str); for (int i = 0; i < strlen(str); i++) res += time[str[i] - 'A']; printf("%d \n", res); return 0; } #include #include using namespace std; int main() { char str[16] = { 0 }; int time[] = { 3..
상수 #include using namespace std; int Reverse(int num) { int a = 0, b = 0, c = 0; a = num / 100; b = (num % 100) / 10; c = (num % 100) % 10; return c * 100 + b * 10 + a; } int main() { int num1, num2; int result = 0; cin >> num1 >> num2; if (Reverse(num1) > Reverse(num2)) result = Reverse(num1); else result = Reverse(num2); cout
단어의 개수 #include int main(void) { char str[1000000] = { 0 }; int cnt = 1; gets(str); //공백 처리를 위함 if (str[0] == ' ') //처음 cnt = cnt - 1; for (int i = 0; str[i] != 0; i++) { if (str[i] == ' ') { cnt++; if (str[i + 1] == 0) //마지막 { if (str[i] == ' ') cnt = cnt - 1; } } } printf("%d \n", cnt); return 0; }