반응형

Programming/Baekjoon 117

백준 10984 내 학점을 구해줘 [c++]

#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.fixed;//소수점고정을 위해 사용 cout.precision(2); int t; cin >> t;//학기의수 int* arr = new int[t];//총 학점을 저장할 배열 double* gpaArr = new double[t];//총 평점을 저장할 배열 int n;//과목의수 int temp[10] = { 0, };//학점을 입력받을 배열 double temp2[10] = { 0, };//성적을 입력받을 배열 int intSum = 0; double doubleSum = 0.0; for (int i = 0;..

백준 2748 피보나치수2 [c++]

#include using namespace std; long long arr[90] = { 0,};//n이 90까지 입력될 수 있기때문에 long long 으로 선언해야 한다. long long func(int n)//재귀함수를 사용하여 피보나치수를 구하고 구한 피보나치 수를 배열에 저장한다. { if (n == 0 || n == 1) return arr[n]; else if (arr[n] == 0) arr[n] = func(n - 1) + func(n - 2); return arr[n]; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; arr[0] = 0;//0번째 피보나치수는 0 ar..

백준 1408 24 [c++]

#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int h, m, s; int h2, m2, s2; scanf("%d:%d:%d", &h, &m, &s);//현재시간 입력 scanf("%d:%d:%d", &h2, &m2, &s2);//임무시작시간 입력 h2 -= h;//임무시작시간에서 현재시간을 뺀다 m2 -= m; s2 -= s; if (s2 < 0)//초단위가 0보다 작으면 60을 더하고 분단위에서 1을 뺀다 { s..

백준 5635 생일 [c++]

#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n=0; cin >> n;//학생의 수 입력 vectorv(n);//첫번째 pair부터 연도,월,일,이름을 입력받을 벡터 for (int i = 0; i > v[i].second.second >> v[i].second.first >> v[i].first.second >> v[i].first.first; //미리선언한 벡터에 순서에 맞춰 입력 } sort(v.begin(), v.end());//오름차순으로 정렬 cout

백준 11098 첼시를도와줘 [c++]

#include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n;//테스트 케이스의 개수 int p;//고려할 선수의 수 int arr[100] = { 0, };//선수의가격을 저장할 배열 int max=0;//가장비싼선수비교를 위한 변수 int num = 0;//인덱스로 사용할 변수 int count = 0; string sarr[100];//선수이름을 저장할 배열 string rarr[100];//결과로 출력될 배열 cin >> n; for (int i = 0; i > p;//고려할선수의수를 입력 for..

백준 1157 단어공부 [c++]

#include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string str;//문자열을 입력받을변수 int arr[26] = { 0, };//각알파벳의 갯수를 저장하기 위한 배열(알파벳은26개존재) int maxNum=0;//가장많은 알파벳을 찾기위한 변수 char result;//결과출력을 위한 변수 cin >> str;//문자열입력 for (int i = 0; i = 'a')//입력한 문자열의 첫알파벳부터 소문자인지 확인 arr[str[i] - 'a'..

반응형