코드업 기초 100제 풀이 (내코드)
1061
#include <stdio.h>
int main(){
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a|b);
return 0;
}
1062
#include <stdio.h>
int main(){
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a^b);
return 0;
}
1063
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a>b ? a:b);
return 0;
}
1064
#include <stdio.h>
int main() {
int a,b,c;
scanf("%d %d %d", &a,&b,&c);
printf("%d",(a<b?a:b)<c ? (a<b ? a:b):c);
return 0;
}
1065
#include <stdio.h>
int main() {
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a%2==0)
printf("%d\n" ,a);
if(b%2==0)
printf("%d\n" ,b);
if(c%2==0)
printf("%d\n" ,c);
return 0;
}
1066
#include <stdio.h>
int main() {
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a%2==0){
printf("even\n");
}else{
printf("odd\n");
}
if(b%2==0){
printf("even\n");
}else{
printf("odd\n");
}
if(c%2==0){
printf("even\n");
}else{
printf("odd\n");
}
return 0;
}
1067
#include <stdio.h>
int main() {
int a;
scanf("%d",&a);
if(a>0)
printf("plus\n");
else if(a<0)
printf("minus\n");
else
printf("0");
if(a%2==0)
printf("even\n");
else
printf("odd\n");
return 0;
}
1068
#include <stdio.h>
int main() {
int total;
scanf("%d" , &total);
if(total>=90 && total<=100){
printf("A");
}
else if(total >= 70 && total<90){
printf("B");
}
else if(total <=69 && total>=40){
printf("C");
}
else if(total >= 0 && total<=39){
printf("D");
}
return 0;
}
1069
#include <stdio.h>
int main() {
char score;
scanf("%c" , &score);
if(score == 'A'){
printf("best!!!");
}
else if(score == 'B'){
printf("good!!");
}
else if(score == 'C'){
printf("run!");
}
else if(score == 'D'){
printf("slowly~");
}
else{
printf("what?");
}
return 0;
}
1070
#include <stdio.h>
int main() {
int season;
scanf("%d",&season);
switch(season){
case 1:
case 2:
printf("winter");
break;
case 3:
case 4:
case 5:
printf("spring");
break;
case 6:
case 7:
case 8:
printf("summer");
break;
case 9:
case 10:
case 11:
printf("fall");
break;
case 12:
printf("winter");
break;
}
return 0;
}
1071
#include <stdio.h>
int main() {
int num;
a:
scanf("%d",&num);
if(num!=0){
printf("%d\n",num);
goto a;
}
return 0;
}
1072
#include<stdio.h>
int main(){
int a, b;
scanf("%d", &a);
for(;a!=0; a--)
{
scanf("%d", &b);
printf("%d\n", b);
}
return 0;
}
1073
#include <stdio.h>
int main() {
int num = 1;
while(num!=0){
scanf("%d",&num);
if(num!=0)
printf("%d\n",num);
}
return 0;
}
1074
#include <stdio.h>
int main() {
int num;
scanf("%d",&num);
for(num;num>0;num--){
printf("%d\n",num);
}
return 0;
}
1075
#include <stdio.h>
int main() {
int num;
scanf("%d",&num);
for(num;num>0;num--){
printf("%d\n",num-1);
}
return 0;
}
1076
#include <stdio.h>
int main(){
int a,i;
scanf("%c",&a);
for(i='a'; i<=a; i++){
printf("%c ",i);
}
return 0;
}
1077
#include <stdio.h>
int main(){
int i,num;
scanf("%d",&num);
for(i=0;i<=num;i++){
printf("%d\n",i);
}
return 0;
}
1078
#include <stdio.h>
int main(){
int total = 0;
int num = 0;
int i;
scanf("%d",&num);
for(i=0;i<=num;i++){
if(i%2==0){
total+=i;
}
}
printf("%d\n",total);
return 0;
}
1079
#include <stdio.h>
int main(){
char correct;
a:
scanf("%c",&correct);
if(correct != 'q'){
printf("%c",correct);
goto a;
}
else{
printf("%c",correct);
}
return 0;
}
1080
#include <stdio.h>
int main(){
int i, a, s=0;
scanf("%d", &a);
for(i=1;;i++){
s += i;
if (s>=a) break;
}
printf("%d", i);
return 0;
}
'IT Study > Programming' 카테고리의 다른 글
[C] codeup 기초 100제[1081:1099] (1) | 2021.06.03 |
---|---|
[C] codeup 기초 100제[1041:1060] (0) | 2021.06.03 |
[C] codeup 기초 100제[1021:1040] (0) | 2021.06.03 |
[C] codeup 기초 100제[:1020] (0) | 2021.01.24 |