C语言实验考试及答案Word下载.docx
- 文档编号:20009808
- 上传时间:2023-01-15
- 格式:DOCX
- 页数:35
- 大小:433.75KB
C语言实验考试及答案Word下载.docx
《C语言实验考试及答案Word下载.docx》由会员分享,可在线阅读,更多相关《C语言实验考试及答案Word下载.docx(35页珍藏版)》请在冰豆网上搜索。
a[i]);
a[M-1]=a[0];
for(i=1;
if(a[i]>
a[M-1])
a[M-1]=a[i];
Maxis%d\n"
a[M-1]);
#include"
stdio.h"
#include"
math.h"
conio.h"
stdlib.h"
#defineN20
{inta[N]={1,20,8,14,7,12,2,19,19,15,13,14,20,10,16,20,7,6,12,12};
doubleav;
FILE*f;
/***********begin***********/
inti;
floats=a[0];
for(i=1;
20;
s+=a[i];
av=s/N;
/************end************/
Aver=%f\n"
av);
f=fopen("
D:
\\exam\\05700904\\PROGOUT.DAT"
"
w"
);
fprintf(f,"
Average=%.2f\n"
fclose(f);
intarrmin(intarr[3][3])
{inti,j,min;
min=arr[0][0];
for(i=0;
3;
for(j=0;
j<
j++)
if(min>
arr[i][j])
min=arr[i][j];
return(min);
{inta[3][3]={4,4,34,7,3,12,5,6,5},i,j,n;
/************found************/
n=arrmin(a);
Theminis:
%d\n"
n);
main()
{inti,a[10];
=10;
/**************found************/
a[i-1]=i;
5;
i++)
a[9-i]=a[i];
%5d"
a[i]);
\n"
intfun(intm)
{
m=(m/100)*((m/10)%10)*(m%10);
return(m);
{intm,s;
printf("
Enterm:
m);
s=fun(m);
Resultis:
s);
NONO();
NONO()
{FILE*fr,*fw;
inti,j,k,m;
fr=fopen("
\\exam\\05700905\\PROGIN.DAT"
r"
fw=fopen("
\\exam\\05700905\\PROGOUT.DAT"
=5;
{fscanf(fr,"
fprintf(fw,"
Productis%d\n"
fun(m));
}
fclose(fr);
fclose(fw);
{inta[10]={10,4,2,7,3,12,5,34,5,9},i,s;
floataver;
s=s+a[i];
aver=(double)s/i;
%f\n"
intnum,k;
clrscr();
k=0;
Pleaseenteranumber:
"
);
num);
do
k=k+num%10;
num/=10;
}while(num);
\n%d\n"
k);
fun(charstr1[])
inti,count=0;
80;
{if(str1[i]>
='
0'
&
str1[i]<
9'
)
count++;
return(count);
{charstr1[80]="
2007-August-15"
;
intn;
Stringis:
%s\n"
str1);
n=fun(str1);
inti;
chars[80];
\\exam\\05700906\\PROGIN.DAT"
\\exam\\05700906\\PROGOUT.DAT"
{fgets(s,80,fr);
TheResultis:
%d\n"
fun(s));
{floatx[1000],sum=0.0,ave,a;
intn=0,i;
Enterdigit:
%f"
a);
while(a>
=0.0&
n<
1000)
sum+=a;
x[n]=a;
n+=1;
ave=sum/n;
Output:
ave=%.2f\n"
ave);
intfun(charstr[])
inti=0,count;
for(i=0;
str[i]!
\0'
count=i+1;
returncount;
ThisIsacProgram"
intcount;
count=fun(str1);
count);
inti,j;
chars1[80];
\\exam\\05700907\\PROGIN.DAT"
\\exam\\05700907\\PROGOUT.DAT"
%s"
s1);
fun(s1));
for(i=1;
s=s+a[i];
#defineM100
{inta,b,c,i;
a=0;
c=0;
=M;
i+=2)
{a+=i;
b=i+1;
c+=b;
sumofevensis%d\n"
c);
sumofoddsis%d\n"
a);
{intm=9,n=84,s1,s2,i;
i=1;
while(i!
=0)
{i=n%m;
n=m;
s1=m;
m=i;
m=9,n=84;
s2=m*n/s1;
TheHighestcommondivisorof%dand%dis%d\n"
m,n,s1);
TheLowestcommonmultipleof%dand%dis%d\n"
m,n,s2);
NONO(m,n,s1,s2);
NONO(intm,intn,ints1,ints2)
{FILE*fw;
\\exam\\05700908\\PROGOUT.DAT"
MaximalCommonDivisorOf%dand%dis%d\n"
MinimalCommonMultipleOf%dand%dis%d\n"
{inta[10]={1,4,2,7,3,12,5,34,5,9},i,min,pos;
min=a[0];
pos=0;
a[i])
min=a[i];
pos=i;
%d,posis:
min,pos);
if(a[i]>
{doublepi;
floati;
pi=%.5f\n"
pi);
NONO(pi);
NONO(doublex)
{FILE*f;
\\exam\\05700909\\PROGOUT.DAT"
x);
intmax;
fun(intarr[],intn)
{intpos,i;
max=arr[0];
n;
if(max<
arr[i])
max=arr[i];
pos=i;
return(pos);
{inta[10]={1,4,2,7,3,12,5,34,5,9},n;
n=fun(a,10);
Themaxis:
max,n);
math.h>
longintfun(intx)
{inti;
longints=1;
for(i=2;
=x;
s*=i;
return(s);
{longintm=12,n=2,s1,s2,s3;
s1=fun(m);
s2=fun(n);
s3=fun(m-n);
Cmnis:
%ld"
s1/s2/s3);
{doublesum;
doublei;
sum=0.0;
for(i=1.0;
i=i+2)
{sum+=1.0/(i*i);
if(1.0/(i*i)<
1e-6)
break;
sum=%.3f\n"
sum);
NONO(sum);
\\exam\\05700910\\PROGOUT.DAT"
sum=%.3f######\n"
{inta[10]={1,5,2,5,6,8,7,4,3,0};
inti,k,n,f=0;
n);
if(a[i]==n)
{f=1;
k=i;
if(f)
%disNo.%d\n"
n,k);
else
%dnotfound!
s=0;
for(i=0;
if(a[i]%2==0)
s=s+a[i];
Theresultis:
s);
for(i=1;
M;
c+=b;
longinti;
pi=1.0;
=400;
pi=pi*(1.0+1.0/(i*(i+2.0)));
pi=pi*2.0;
\\exam\\05700810\\PROGOUT.DAT"
st
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 实验 考试 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)