Created
June 28, 2020 03:25
-
-
Save dalcon10028/1dc4d85c67d451a819f33379e78de56f to your computer and use it in GitHub Desktop.
2주차 소스코드
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1330번 두 수 비교하기 | |
| #include <stdio.h> | |
| int main() | |
| { | |
| int a,b; | |
| scanf("%d %d", &a, &b); | |
| if(a>b) | |
| printf(">"); | |
| else if(a<b) | |
| printf("<"); | |
| else | |
| printf("=="); | |
| return 0; | |
| } | |
| // 9498번 시험 성적 | |
| #include <stdio.h> | |
| int main() { | |
| int mark; | |
| scanf("%d",&mark); | |
| if(90<=mark && mark<=100) printf("A"); | |
| else if(80<=mark && mark<90) printf("B"); | |
| else if(70<=mark && mark<80) printf("C"); | |
| else if(60<=mark && mark<70) printf("D"); | |
| else printf("F"); | |
| return 0; | |
| } | |
| // 2753번 윤년 | |
| #include <stdio.h> | |
| int main(){ | |
| int year; | |
| scanf("%d", &year); | |
| if((year%4==0 && year%100!=0) || year%400==0) | |
| printf("1"); | |
| else printf("0"); | |
| } | |
| // 14681번 사분면 고르기 | |
| #include <stdio.h> | |
| int main(){ | |
| int x, y; | |
| scanf("%d %d", &x, &y); | |
| // 1사분면 x가 양수 y도 양수 | |
| if(x>0 && y>0) printf("1"); | |
| // 2사분면 x가 음수 y는 양수 | |
| if(x<0 && y>0) printf("2"); | |
| // 3사분면 x가 음수 y도 음수 | |
| if(x<0 && y<0) printf("3"); | |
| // 4사분면 x가 양수 y는 음수 | |
| if(x>0 && y<0) printf("4"); | |
| } | |
| // 2883번 알람 시계 | |
| #include <stdio.h> | |
| int main(){ | |
| int h, m; | |
| scanf("%d %d", &h, &m); | |
| if((m-=45)<0){ | |
| m+=60; h--; | |
| if(h<0) h+=24; | |
| } | |
| printf("%d %d", h, m); | |
| } | |
| // 2739번 구구단 | |
| #include <stdio.h> | |
| int main(){ | |
| int n, i; | |
| scanf("%d", &n); | |
| for(i=1; i<=9; i++) | |
| printf("%d * %d = %d\n", n, i, n*i); | |
| } | |
| // 10950번 A+B - 3 | |
| #include <stdio.h> | |
| int main() { | |
| int a, b, c, i; | |
| scanf("%d",&a); | |
| for(i=0;i<a;i++){ | |
| scanf("%d %d",&b,&c); | |
| printf("%d\n",b+c); | |
| } | |
| return 0; | |
| } | |
| // 8393번 합 | |
| #include <stdio.h> | |
| int main() { | |
| int a,i,sum=0; | |
| scanf("%d",&a); | |
| for(i=1;i<=a;i++) sum+=i; | |
| printf("%d",sum); | |
| return 0; | |
| } | |
| // 11021번 A+B - 7 | |
| #include <stdio.h> | |
| int main() { | |
| int t, i, a, b; | |
| scanf("%d", &t); | |
| for(i=1; i<=t; i++){ | |
| scanf("%d %d", &a, &b); | |
| printf("Case #%d: %d\n", i, a+b); | |
| } | |
| return 0; | |
| } | |
| // 11022번 A+B -8 | |
| #include <stdio.h> | |
| int main() { | |
| int t, i, a, b; | |
| scanf("%d", &t); | |
| for(i=1; i<=t; i++){ | |
| scanf("%d %d", &a, &b); | |
| printf("Case #%d: %d + %d = %d\n", i, a, b, a+b); | |
| } | |
| return 0; | |
| } | |
| // 2438번 별 찍기 - 1 | |
| #include <stdio.h> | |
| int main(){ | |
| int a,i,j ; | |
| scanf("%d",&a); | |
| for(i=0; i<a; i++){ | |
| for(j=0;j<=i;j++) | |
| printf("*"); | |
| printf("\n"); | |
| } | |
| return 0; | |
| } | |
| // 2439번 별 찍기 - 2 | |
| #include <stdio.h> | |
| int main(){ | |
| int a,i,j,k ; | |
| scanf("%d",&a); | |
| for(i=0; i<a; i++){ | |
| for(k=1;k<(a-i);k++) | |
| printf(" "); | |
| for(j=0;j<=i;j++) | |
| printf("*"); | |
| printf("\n"); | |
| } | |
| return 0; | |
| } | |
| // 10871번 X 보다 작은 수 | |
| #include <stdio.h> | |
| int main(){ | |
| int N, X, i; | |
| int sequence[10000]; | |
| scanf("%d %d",&N,&X); | |
| for(i=0;i<N;i++) | |
| scanf("%d", &sequence[i]); | |
| for(i=0;i<N;i++){ | |
| if(sequence[i]<X) printf("%d ",sequence[i]); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment