简单C语言及运行结果Word格式.docx
- 文档编号:16257495
- 上传时间:2022-11-22
- 格式:DOCX
- 页数:21
- 大小:139.85KB
简单C语言及运行结果Word格式.docx
《简单C语言及运行结果Word格式.docx》由会员分享,可在线阅读,更多相关《简单C语言及运行结果Word格式.docx(21页珍藏版)》请在冰豆网上搜索。
charc1,c2;
scanf("
a=%db=%d"
&
a,&
b);
%f%e"
x,&
y);
%c%c"
c1,&
c2);
a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%c\n"
a,b,x,y,c1,c2);
6.#include<
{charc1='
C'
c2='
h'
c3='
i'
c4='
n'
c5='
a'
;
c1=c1+4;
c2=c2+4;
c3=c3+4;
c4=c4+4;
c5=c5+4;
passworis%c%c%c%c%c\n"
c1,c2,c3,c4,c5);
7.#include<
intmain()
{floath,r,l,s,sq,vq,vz;
floatpi=3.141526;
请输入圆半径r,圆柱高h∶"
);
%f,%f"
r,&
h);
//要求输入圆半径r和圆柱高h
l=2*pi*r;
//计算圆周长l
s=r*r*pi;
//计算圆面积s
sq=4*pi*r*r;
//计算圆球表面积sq
vq=3.0/4.0*pi*r*r*r;
//计算圆球体积vq
vz=pi*r*r*h;
//计算圆柱体积vz
圆周长为:
l=%6.2f\n"
l);
圆面积为:
s=%6.2f\n"
s);
圆球表面积为:
sq=%6.2f\n"
sq);
圆球体积为:
v=%6.2f\n"
vq);
圆柱体积为:
vz=%6.2f\n"
vz);
}
第4章
3.
(1)0
(2)1(3)1(4)0(5)1
4.#include<
{
inta,b,c;
请输入三个整数:
"
%d,%d,%d"
b,&
c);
if(a<
b)
if(b<
c)
max=%d\n"
c);
else
b);
elseif(a<
a);
{intx,y;
输入x:
%d"
x);
if(x<
1)/*x<
1*/
{y=x;
x=%3d,y=x=%d\n"
x,y);
elseif(x<
10)/*1=<
x<
10*/
{y=2*x-1;
x=%d,y=2*x-1=%d\n"
x,y);
else/*x>
=10*/
{y=3*x-11;
x=%d,y=3*x-11=%d\n"
7.
(1)#include<
intx,y;
enterx:
y=-1;
if(x!
=0)
if(x>
0)
y=1;
y=0;
x=%d,y=%d\n"
pleaseenterx:
0)y=1;
elsey=-1;
8.#include<
{floatscore;
chargrade;
请输入学生成绩:
%f"
score);
while(score>
100||score<
{printf("
\n输入有误,请重输"
switch((int)(score/10))
{case10:
case9:
grade='
A'
break;
case8:
B'
case7:
case6:
D'
case5:
case4:
case3:
case2:
case1:
case0:
E'
成绩是%5.1f,相应的等级是%c\n"
score,grade);
11.#include<
{intt,a,b,c,d;
请输入四个数:
%d,%d,%d,%d"
c,&
d);
a=%d,b=%d,c=%d,d=%d\n"
a,b,c,d);
if(a>
{t=a;
a=b;
b=t;
a=c;
c=t;
d)
a=d;
d=t;
if(b>
{t=b;
b=c;
b=d;
if(c>
{t=c;
c=d;
排序结果如下:
\n"
%d%d%d%d\n"
a,b,c,d);
第5章
{doubles=0,t=1;
intn;
for(n=1;
n<
=20;
n++)
{
t=t*n;
s=s+t;
1!
+2!
+...+20!
=%22.15e\n"
intn1=100,n2=50,n3=10;
doublek,s1=0,s2=0,s3=0;
for(k=1;
k<
=n1;
k++)/*计算1到100的和*/
{s1=s1+k;
=n2;
k++)/*计算1到50各数的平方和*/
{s2=s2+k*k;
=n3;
k++)/*计算1到10的各倒数和*/
{s3=s3+1/k;
sum=%15.6f\n"
s1+s2+s3);
10.#include<
inti,n=20;
doublea=2,b=1,s=0,t;
for(i=1;
i<
=n;
i++)
s=s+a/b;
t=a,
a=a+b,
b=t;
sum=%16.10f\n"
16.#include<
{inti,j,k;
for(i=0;
=3;
{for(j=0;
j<
=2-i;
j++)
"
for(k=0;
=2*i;
k++)
*"
\n"
=2;
=i;
=4-2*i;
第6章
3.#include<
inta[3][3],sum=0;
inti,j;
enterdata:
3;
for(j=0;
%3d"
a[i][j]);
sum=sum+a[i][i];
sum=%6d\n"
sum);
{inta[11]={1,4,6,9,13,16,19,28,40,100};
inttemp1,temp2,number,end,i,j;
arraya:
10;
%5d"
a[i]);
insertdata:
number);
end=a[9];
if(number>
end)
a[10]=number;
{for(i=0;
{if(a[i]>
number)
{temp1=a[i];
a[i]=number;
for(j=i+1;
11;
{temp2=a[j];
a[j]=temp1;
temp1=temp2;
break;
Nowarraya:
{chara[5]={'
*'
'
};
inti,j,k;
charspace='
'
5;
{printf("
for(j=1;
%c"
space);
a[k]);
13.#include<
{chars1[80],s2[40];
inti=0,j=0;
inputstring1:
%s"
s1);
inputstring2:
s2);
while(s1[i]!
='
\0'
)
i++;
while(s2[j]!
s1[i++]=s2[j++];
s1[i]='
\nThenewstringis:
%s\n"
15.#include<
#include<
string.h>
{chars1[80],s2[80];
inti;
inputs2:
=strlen(s2);
s1[i]=s2[i];
s1:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 语言 运行 结果
![提示](https://static.bdocx.com/images/bang_tan.gif)