第一题的:
#include<stdioh>
int main()
{
char c;
scanf("%c",&c);
if('a'<=c&&c<='z')
printf("%c\n",char(c-32));
else if('A'<=c&&c<='Z')
printf("%c\n",char(c+32));
else
printf("what you input is not a letter! ");
return 0;
}
第二题的:
#include<stdioh>
int main()
{ int x,y;
printf("Please input your number x:\n");
scanf("%d",&x);
if(x>-1)
y=2x;
else if(x<-1)
y=4+x;
else y=3;
printf("%d",y);
return 0;
}
第三题:
#include<stdioh>
int main()
{
int n;
printf("Please input a integer number:\n");
scanf("%d",&n);
(n%2==0)(printf("%d is Even\n",n)):(printf("%d is Odd\n",n));
return 0;
}
第四题的:
#include<stdioh>
int main()
{
float x,y;
printf("请输入员工的业绩金额(万元):\n");
scanf("%f",&x);
if(x<1)
y=103x;
else if(x>=1&&x<5)
y=11x;
else if(x>=5&&x<20)
y=15x;
else y=12x;
printf("该员工的奖金数是%g万元\n",y);
return 0;
}
百度有很多这个教程的答案,非常多。你自己根据需求去下《C语言程序设计实验指导与习题解答》是与孙力主编的《C语言程序设计》(中国农业出版社出版)配套使用的实验指导书。全书共有4章。第1章是C语言编译环境介绍,主要介绍了VisualC++60集成开发环境下编辑、编译、调试和运行程序的方法。第2章是上机实验内容,编写了配合《C语言程序设计》上机实验的47个实验和1个综合实训,实验内容循序渐进,由浅入深,分别由基础性实验、提高性实验、综合性和设计性实验构成。第3章是程序开发中的常见错误与调试。第4章是《C语言程序设计》每章末部分习题的参考答案。
//如果是老谭的,你看看下面是否是你要的。
第三章 34
main()
{int a,b,c;
long int u,n;
float x,y,z;
char c1,c2;
a=3;b=4;c=5;
x=12;y=24;z=-36;
u=51274;n=128765;
c1='a';c2='b';
printf("\n");
printf("a=%2d b=%2d c=%2d\n",a,b,c);
printf("x=%86f,y=%86f,z=%96f\n",x,y,z);
printf("x+y=%52f y+z=%52f z+x=%52f\n",x+y,y+z,z+x);
printf("u=%6ld n=%9ld\n",u,n);
printf("c1='%c'or %d(ASCII)\n",c1,c1);
printf("c2='%c'or %d(ASCII)\n",c2,c2);
}
35
57
5 7
67856400,-789123962
67856400,-789123962
6786 -78912,67856400,-789123962,67856400,-789123962
6785640e+001,-789e+002
A,65,101,41
1234567,4553207,d687
65535,177777,ffff,-1
COMPUTER, COM
36
a=3 b=7/
x=85 y=7182/
c1=A c2=a/
37
10 20Aa15 -375 +14,678/
(空 3)10(空3)20Aa15(空1)-375(空1)(随意输入一个数),678 回车
38
main()
{float pi,h,r,l,s,sq,sv,sz;
pi=31415926;
printf("input r,h\n");
scanf("%f,%f",&r,&h);
l=2pir;
s=rrpi; sq=4pirr;
sv=40/30pirrr;
sz=pirrh;
printf("l=%62f\n",l);
printf("s=%62f\n",s);
printf("sq=%62f\n",sq);
printf("vq=%62f\n",sv);
printf("vz=%62f\n",sz);
}
39
main()
{float c,f;
scanf("%f",&f);
c=(50/90)(f-32);
printf("c=%52f\n",c);
}
310
#include"stdioh"
main()
{char c1,c2;
scanf("%c,%c",&c1,&c2);
putchar(c1);
putchar(c2);
printf("\n");
printf("%c%c\n",c1,c2);
}
第四章
43
(1)0 (2)1 (3)1 (4)0 (5)1
44
main()
{int a,b,c;
scanf("%d,%d,%d",&a,&b,&c);
if(a<b)
if(b<c)
printf("max=%d\n",c);
else
printf("max=%d\n",b);
else if(a<c)
printf("max=%d\n",c);
else
printf("max=%d\n",a);
}
main() {int a,b,c,temp,max;
scanf("%d,%d,%d",&a,&b,&c);
temp=(a>b)a:b;
max=(c>temp)c:temp;
printf("max=%d",max);
}
45
main()
{int x,y;
scanf("%d",&x);
if(x<1)y=x;
else if(x<10)y=2x-1;
else y=3x-11;
printf("y=%d",y);
}
46
main()
{int score,temp,logic;
char grade;
logic=1;
while(logic)
{scanf("%d",&score);
if(score>=0&&score<=100)logic=0;
}
if(score==100)
temp=9;
else
temp=(score-score%10)/10;
switch(temp)
{case 9:grade='A';break;
case 8:grade='B';break;
case 7:grade='C';break;
case 6:grade='D';break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:grade='E';
}
printf"score=%d,grade=%c",score,grade);
}
47 main()
{long int num;
int indiv,ten,hundred,thousand,ten_thousand,place;
scanf("%ld",&num);
if(num>9999) place=5;
else if(num>999) place=4;
else if(num>99) place=3;
else if(num>9) place=2;
else place=1;
printf("place=%d\n",place);
ten_thousand=num/10000;
thousand=(num-ten_thousand10000)/1000;
hundred=(num-ten_thousand10000-thousand1000)/100;
ten=(num-ten_thousand10000-thousand1000-hundred100)/10;
indiv=num-ten_thousand10000-thousand1000-hundred100-ten10;
switch(place)
{case 5:printf("%d,%d,%d,%d,%d\n",ten_thousand,thousand,hundred,ten,indiv);
printf("%d,%d,%d,%d,%d\n",indiv,ten,hundred,thousand,ten_thousand);
break;
case 4:printf("%d,%d,%d,%d\n",thousand,hundred,ten,indiv);
printf("%d,%d,%d,%d\n",indiv,ten,hundred,thousand);
break;
case 3:printf("%d,%d,%d\n",hundred,ten,indiv);
printf("%d,%d,%d\n",indiv,ten,hundred);
break;
case 2:printf("%d,%d\n",ten,indiv);
printf("%d,%d\n",indiv,ten);
break;
case 1:printf("%d\n",indiv);
printf("%d\n",indiv);
}
}
48
main()
{long i;
float bonus,bon1,bon2,bon4,bon6,bon10;
bon1=10000001;
bon2=bon1+1000000075;
bon4=bon2+200000005;
bon6=bon4+200000003;
bon10=bon6+4000000015;
scanf("%ld",&i);
if(i<=1e5)bonus=i01;
else if(i<=2e5)bonus=bon1+(i-100000)0075; else if(i<=4e5)bonus=bon2+(i-200000)005;
else if(i<=6e5)bonus=bon4+(i-400000)003;
else if(i<=1e6)bonus=bon6+(i-600000)0015;
else bonus=bon10+(i-1000000)001;
printf("bonus=%102f",bonus);
}
main()
{long i;
float bonus,bon1,bon2,bon4,bon6,bon10;
int branch;
bon1=10000001;
bon2=bon1+1000000075;
bon4=bon2+200000005;
bon6=bon4+200000003;
bon10=bon6+4000000015;
scanf("%ld",&i);
branch=i/100000;
if(branch>10)branch=10;
switch(branch)
{case 0:bonus=i01;break;
case 1:bonus=bon1+(i-100000)0075;break;
case 2:
case 3:bonus=bon2+(i-200000)005;break;
case 4:
case 5:bonus=bon4+(i-400000)003;break;
case 6:
case 7
case 8:
case 9:bonus=bon6+(i-600000)0015;break;
case 10:bonus=bon10+(i-1000000)001;
}
printf("bonus=%102f",bonus);
}
49
main()
{int t,a,b,c,d;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
if(a>b){t=a;a=b;b=t;}
if(a>c){t=a;a=c;c=t;}
if(a>d){t=a;a=d;d=t;}
if(b>c){t=b;b=c;c=t;}
if(b>d){t=b;b=d;d=t;}
if(c>d){t=c;c=d;d=t;} printf("%d %d %d %d\n",a,b,c,d);
}
410
main()
{int h=10;
float x,y,x0=2,y0=2,d1,d2,d3,d4;
scanf("%f,%f",&x,&y);
d1=(x-x0)(x-x0)+(y-y0)(y-y0);
d2=(x-x0)(x-x0)+(y+y0)(y+y0);
d3=(x+x0)(x+x0)+(y-y0)(y-y0);
d4=(x+x0)(x+x0)+(y+y0)(y+y0);
if(d1>1&&d2>1&&d3>1&&d4>1)h=0;
printf("h=%d",h);
}
大学学习资料免费下载网 有类似资料
在 其他公共课程 版块
标题:陈东方 C语言程序设计基础实验与题解(答案)
中国物联网校企联盟技术部
以上就是关于C语言程序设计,求答案。万分感谢!全部的内容,包括:C语言程序设计,求答案。万分感谢!、求孙亚飞主编的C语言程序设计的课后答案啊啊、c语言第四章的答案等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)