본문 바로가기

전체 글

(52)
[백준] 10828번 스택 c++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int testCase; int num; string command; cin >> testCase; stack s; for (int i = 0; i > command; if (command == "push") { cin >> num; s.push(num); } else if (command == "pop") { if (s.size()) { cout
[백준] 1406번 에디터 C++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); string data; char imruk; int num; list lis; cin >> data; for (auto a : data) lis.push_back(a); auto cursor = lis.end(); cin >> num; while (num--) { cin >> imruk; if (imruk == 'P') { char special; cin >> special; lis.insert(cursor, special); } else if (imruk == 'L') { if (cursor != lis.begin()) { cursor--; } } els..
[백준] 1919번 애너그램 만들기 c++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); string s1; string s2; int count = 0; int beforeCount = 0; int arr[26] = { 0, }; int arr2[26] = { 0, }; cin >> s1; cin >> s2; for (int i = 0; i < s1.size(); i++) { arr[s1[i] - 'a']++; } for (int i = 0; i < s2.size(); i++) { arr2[s2[i] - 'a']++; } for (int i = 0; i < 26; i++) { if (arr[i] != arr2[i]) { count += abs..
[백준] 11328번 Strfry C++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int testCase; string te1, te2; cin >> testCase; int arr[26] = { 0, }; int arr2[26] = { 0, }; int count = 0; for (int i = 0; i > te1; cin>> te2; for (int i = 0; i < te1.size(); i++) { arr[te1[i] - 'a']++; } for (int i = 0; i < te2.size(); i++) { arr2[te2[i] - 'a']++; } for (int i = 0; i < 2..
[백준] 1475번 방 번호 c++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int roomNumber; int sum = 0; float max = 0; cin >> roomNumber; float num[10] = { 0, }; //1~9까지 담아줌 if (roomNumber == 0) { //반례 첫 번째 0이 입력되면 1개를 쓰는거임 cout 0) { //0보다 큰수가 입력이 될 때 if (roomNumber % 10 == 6 || roomNumber % 10 == 9) { //6과 9는 서로 바꿔 쓸 수 있으니까 6과 9가 나오면 0.5씩 더해줌 생각해보면 말 됨 num[9] += 0.5; roomNumber /= 10; ..
[백준] 13300 방 배정 c++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int studentNum,max; int minRoom = 0; int sex, grade; int arrGirl[6] = {0,}; //각 학년의 수를 담을 배열 0이면 여자 int arrMan[6] = {0,}; //각 학년의 수를 담을 배열 1이면 남자 cin >> studentNum >> max; for (int i = 0; i > sex >> grade; if (sex == 0) arrGirl[grade - 1]++; else arrMan[grade - 1]++; } for (int i = 0; i ..
[백준] 10807번 개수 세기 c++ #include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int arr[101] = {}; int num; int count = 0; cin >> num; for (int i = 0; i > arr[i]; } int find; cin >> find; for (int i = 0; i < num; i++) { if (arr[i] == find) count++; } cout
[백준] 10808번 알파벳 개수 C++ #include using namespace std; int main(void) { string str; cin >> str; int arr[26] = { 0, }; for (int i = 0; i < str.size(); i++) { arr[str[i] - 'a']+=1; } for (int n : arr) cout