标签:
#include <stdio.h>
int main(){
int a,b,c,t;
printf("请输入三个整数:");
scanf("%d%d%d",&a,&b,&c);
if(a<b){
t = a;
a = b;
b = t;
}
if(b>c){
printf("%d\t%d\t%d\n",a,b,c);
}
else if(c>a){
printf("%d\t%d\t%d\n",c,a,b);
}
else{
printf("%d\t%d\t%d\n",a,c,b);
}
return 0;
}

实验2-2
#include <stdio.h>
#include <math.h>
int main(){
int x,y;
printf ("请输入x值:");
scanf("%d",&x);
if(x>4){
y=sqrt(x-4);
printf("%d\n",y);
}
else if(x<-5){
y=fabs(x);
printf("%d\n",y);
}
else{
y=x+3;
printf("%d\n",y);
}
return 0;
}

实验2-3
#include <stdio.h>
int main(){
char c;
printf("请输入字符:\n");
scanf("%c",&c);
printf("大写字符为:%c\n",c-32);
}

实验2-4
#include <stdio.h>
#include <math.h>
int main(){
int x,y;
printf("输入X:");
scanf("%d",&x);
if(x<1){
y=x;
printf("%d\n",y);
}
else if(1<=x && x<10){
y=(2*x-1);
printf("%d\n",y);
}
else{
y=(3*x-11);
printf("%d\n",y);
}
return 0;
}

#include <stdio.h>
int main(){
int x;
printf ("输入成绩:");
scanf("%d",&x);
if(x>=90)
printf("A");
else if(x>=80 && x<=89)
printf("B");
else if(x>=70 && x<=79)
printf("C");
else if(x>=60 && x<=69)
printf("D");
else
printf("E");
}

实验心得:
这次作业整体来说做的还是比较顺利的,虽然还是得看书,但是感觉自己进步还是很大的。第一题不知道什么原因最后输出的是乱码?希望老师解答一下。
标签:
原文地址:http://www.cnblogs.com/nkbest/p/5912391.html