Created
July 8, 2020 00:50
-
-
Save dalcon10028/cc1eaadbf3df6f5d2fc47dea721be384 to your computer and use it in GitHub Desktop.
3주차 소스코드
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
// 2741번 N 찍기 | |
#include <stdio.h> | |
int main() { | |
int a,i ; | |
scanf("%d",&a); | |
for(i=1; i<=a; i++) | |
printf("%d\n",i); | |
return 0; | |
} | |
// 2742번 기찍 N | |
#include <stdio.h> | |
int main() { | |
int a,i ; | |
scanf("%d",&a); | |
for(i=0; i<a; i++) | |
printf("%d\n",a-i); | |
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; | |
} | |
// 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; | |
} | |
// 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; | |
} | |
// A+B - 5 | |
#include <stdio.h> | |
int main() { | |
int a, b; | |
do{ | |
scanf("%d %d", &a, &b); | |
if(!(a==0 && b==0)) | |
printf("%d\n", a+b); | |
}while(!(a==0 && b==0)); | |
return 0; | |
} | |
// 더하기 사이클 | |
#include <stdio.h> | |
int tens(int num){ | |
int tens; | |
tens=num/10; | |
return tens; | |
} | |
int units(int num){ | |
int units; | |
units=num-tens(num)*10; | |
return units; | |
} | |
int main(){ | |
int N, cycle, count=0, t, u; | |
scanf("%d", &N); | |
cycle=N; | |
do{ | |
t=tens(cycle); | |
u=units(cycle); | |
cycle=u*10+units(t+u); | |
count++; | |
}while(cycle!=N); | |
printf("%d", count); | |
} | |
// 2562번 최댓값 | |
#include <stdio.h> | |
int main() { | |
int i,num,max=0; | |
int n[9]; | |
for(i=0; i<9; i++){ | |
scanf("%d", &n[i]); | |
if(n[i]>max){ | |
num=i; | |
max=n[i]; | |
} | |
} | |
printf("%d\n%d", max, num+1); | |
return 0; | |
} | |
// 11654번 아스키 코드 | |
#include <stdio.h> | |
int main(void) { | |
char a; | |
scanf("%c",&a); | |
printf("%d", (char)a); | |
return 0; | |
} | |
// 2908번 상수 | |
#include <stdio.h> | |
int main() { | |
char A[3]; | |
char B[3]; | |
scanf("%s %s", A, B); | |
if(A[2]>B[2]) | |
printf("%c%c%c",A[2],A[1],A[0]); | |
else if(A[2]<B[2]) | |
printf("%c%c%c",B[2],B[1],B[0]); | |
else{ | |
if(A[1]>B[1]) | |
printf("%c%c%c",A[2],A[1],A[0]); | |
else if(A[1]<B[1]) | |
printf("%c%c%c",B[2],B[1],B[0]); | |
else{ | |
if(A[0]>B[0]) | |
printf("%c%c%c",A[2],A[1],A[0]); | |
else if(A[0]<B[0]) | |
printf("%c%c%c",B[2],B[1],B[0]); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment