## C语言学习之部分51nod启蒙练习编码

2393 启蒙练习-取余

``````#include <stdio.h>
main(){
int x;
int y;
scanf("%d %d",&x,&y);
printf("%d\n",x%y);
}
``````

2394 启蒙练习-四则运算1

``````#include <stdio.h>
main(){
int a;
int b;
int c;
scanf("%d %d %d",&a,&b,&c);
printf("%d\n",a*(b+c-a));
}
``````

2395 启蒙练习-函数1

``````#include <stdio.h>
main(){
int x;
scanf("%d",&x);
printf("%d\n",x*x+2*x+5);
}
``````

2396 启蒙练习-圆的面积

``````#include<stdio.h>
main(){
float r;
scanf("%f",&r);
printf("%f\n",r*r*3.14159);

}
``````

2397 启蒙练习-直角三角形`

``````#include<stdio.h>
main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a*a+b*b==c*c){
printf("%d\n",1);
}else{
printf("%d\n",0);
}
}
``````

2399 启蒙练习-条件输出1

``````#include<stdio.h>
main(){
int a,b;
scanf("%d%d",&a,&b);
if(a+b>10){
printf("%d\n",a*b);
}else{
printf("%d\n",a-b);
}
}
``````

2400 启蒙练习-条件输出2

``````#include<stdio.h>
main(){
int a,b;
scanf("%d%d",&a,&b);
if(a+b>=0 && a+b<=3){
printf("YES\n");
}else if(a+b>=4){
printf("NO\n");
}else{
printf("negative\n");
}
}
``````

2402 启蒙练习-条件输出3

``````#include<stdio.h>
main(){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a+b>10){
printf("%d\n",a*b);
}else if(b+c>5){
printf("%d\n",c*d);
}else if(d<10 || a*c>100){
printf("YES\n");
}else{
printf("NO\n");
}
}
``````

2410 启蒙练习-分数评级

``````#include<stdio.h>
main(){
int S;
scanf("%d",&S);
if(S>=90&&S<=100){
printf("A\n");
}else if(S>=80&&S<90){
printf("B\n");
}else if(S>=70&&S<80){
printf("C\n");
}else if(S>=60&&S<70){
printf("D\n");
}else if(S<60&&S>0){
printf("E\n");
}
}
``````

2401 启蒙练习-首字母

``````#include<stdio.h>
main(){
char character;
scanf("%c",&character);
switch(character){
case 97:
printf("apple\n");
break;
case 98:
printf("banana\n");
break;
case 99:
printf("cat\n");
break;
default:
printf("no\n");
}
}
``````

2403 启蒙练习-求和

``````#include<stdio.h>
main(){
int a,b,c;
scanf("%d%d",&a,&b);
switch(c=a+b){
case 1:
printf("one\n");
break;
case 2:
printf("two\n");
break;
case 3:
printf("three\n");
break;
case 4:
printf("four\n");
break;
case 5:
printf("five\n");
break;
case 6:
printf("six\n");
break;
case 7:
printf("seven\n");
break;
case 8:
printf("eight\n");
break;
case 9:
printf("nine\n");
break;
default:
printf("None\n");
}
}
``````

0条评论