끄적끄적 코딩
article thumbnail
[C++] 백준 4344번 평균은 넘겠지
알고리즘 2019. 3. 5. 21:16

평균을 넘는 사람이 몇퍼센트인지 출력하는 문제입니다. #include using namespace std; int main(int argc, char * argv[]) { double c1, c2; double count; double avg; double arr[10000]; cin >> c1; cout > c2; count = 0; avg = 0; for (int j = 0; j > arr[j]; avg += arr[j]; } avg /= c2; for (int j = 0; j avg) { count++; } } cout

article thumbnail
[C++] 백준 1546번 평균
알고리즘 2019. 3. 5. 14:33

맥스값을 구한 후 새로운 계싼법으로 계산을 해줍니다. 그 후 평균을 구하면 됩니다. #include using namespace std; int main(int argc, char *argv[]) { int a,i,j; cin >> a; double b[a], max, result; for(i=0;i> b[i]; if(max

article thumbnail
[C++] 백준 10871번 X보다 작은 수
알고리즘 2019. 3. 5. 14:32

배열 z에 값들을 넣고 y보다 작을 경우 배열 t에서 체크를 합니다. 0~10000의 범위에 있기때문에 t[10000]을 만들어주고 -1로 초기화해주었습니다. 그리고 z[i]가 y보다 작으면 t[c++] = z[i]를 해줍니다. 값의 비교가 끝났으면 배열 t에 있는 값들을 출력합니다. #include using namespace std; int main(int argc, char * argv[]) { int x, y, z[10000], t[10000], c = 0; cin >> x; cin >> y; for (int i = 0; i > z[i]; if (z[i] < y) { t[c++] = ..

article thumbnail
[C++] 백준 10817번 세 수
알고리즘 2019. 3. 5. 14:17

if문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char * argv[]) { int x, y, z; cin >> x; cin >> y; cin >> z; if (x >= y && y >= z || z >= y && y >= x) { cout = z || z >= x && x >= y) { cout = y || y >= z && z >= x) { cout

article thumbnail
[C++] 백준 9498번 시험 성적
알고리즘 2019. 3. 5. 14:13

if문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char * argv[]) { int x; cin >> x; if(x>=90){ cout

article thumbnail
[C++] 백준 15552번 빠른 A+B
알고리즘 2019. 3. 5. 14:05

빠른 시간에 문제를 풀어야 합니다. cin과 cout보다 printf와 scanf가 속도가 빠릅니다. #include #include using namespace std; int main(int argc, char * argv[]) { int c=0; int x, y; scanf("%d", &c); for (int i = 0; i < c; i++) { scanf("%d", &x); scanf("%d", &y); printf("%d\n", x + y); } return 0; }

article thumbnail
[C++] 백준 11721번 열 개씩 끊어 출력하기
알고리즘 2019. 3. 5. 14:02

string에 입력을 받은 후 substr 함수로 10글자씩 잘라서 출력합니다. #include #include using namespace std; int main(int argc, char * argv[]) { string s; cin >> s; int ten = s.size() / 10; int won = s.size() % 10; for (int i = 1; i

article thumbnail
[C++] 백준 11720번 숫자의 합
알고리즘 2019. 3. 5. 13:52

입력된 값들의 숫자를 하나하나 더해서 출력하는 문제입니다. int나 double로 받게 될 경우 범위를 넘는 경우가 생길 수 있어서 string으로 입력을 받았습니다. stoi함수를 이용해서 string을 int로 바꾸고 substr함수로 한 글자씩 잘라서 sum에 추가해주었습니다. #include #include using namespace std; int main(int argc, char * argv[]) { int a; int i = 0; string s; int sum = 0; cin >> a; cin >> s; for (int i = 1; i

검색 태그