皖西学院c语言上机题Word格式文档下载.docx

上传人:b****1 文档编号:1514036 上传时间:2023-04-30 格式:DOCX 页数:33 大小:22.23KB
下载 相关 举报
皖西学院c语言上机题Word格式文档下载.docx_第1页
第1页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第2页
第2页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第3页
第3页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第4页
第4页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第5页
第5页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第6页
第6页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第7页
第7页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第8页
第8页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第9页
第9页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第10页
第10页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第11页
第11页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第12页
第12页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第13页
第13页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第14页
第14页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第15页
第15页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第16页
第16页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第17页
第17页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第18页
第18页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第19页
第19页 / 共33页
皖西学院c语言上机题Word格式文档下载.docx_第20页
第20页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

皖西学院c语言上机题Word格式文档下载.docx

《皖西学院c语言上机题Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《皖西学院c语言上机题Word格式文档下载.docx(33页珍藏版)》请在冰点文库上搜索。

皖西学院c语言上机题Word格式文档下载.docx

longbwage,bonus,ins,rwage;

};

{

sructemployeeNK1$*/

inti;

longtotal;

total=0;

/*$BLANK2$*/

Pleaseinputdata:

\nnumnamebwagebonusins:

for(i=0;

i<

N;

i++)

scanf("

%ld%s"

&

worker[i].num,worker[i].name);

%ld%ld%ld"

worker[i].bwage,&

worker[i].bonus,&

worker[i].ins);

{

Worker[i].rwage=worker[i].bonus-worker[i].ins;

/$BLANK3$*/

total=total+worker[i].rwage;

output:

\n"

\nnumnamerealwage\n"

%-9ld%-14s%-ld\n"

worker[i].num,worker[i].name,worker[i].rwage);

\ntotalwage=%ld\n"

total);

试卷1程序题

某果农有一车水果,第一天卖掉三分之而后吃了两个,第二天卖掉了剩下的三分之二又吃了两个,第三天到第七天都如此,到第八天一看只剩了五个苹果。

求此车共装有多少个苹果(要求用循环实现)。

参考程序1

voidPRINT(ints)

FILE*out;

s=%d\n"

s);

if((out=fopen("

C:

\\24000110\\RESULT.DAT"

"

w+"

))!

=NULL)

fprintf(out,"

s=%d"

fclose(out);

inti;

s=5;

for(i=1;

8;

I++)

s=(s+2)*3;

PRINT(s);

试卷2改错题

计算所有三位正整数中各个数位上数字之和是13的数的总和。

如将139、148、157等这样的数求和。

inti,j,s;

longsum;

sum=1;

/*$ERROR1$*/改为sum=0;

for(i=100;

=999;

i++)

j=i;

s=0;

while(j>

1)/*$ERROR2$*/改为while(j<

s=s+j/10;

/*$ERROR3$*/改为s=s+j%10;

j=j/10;

if(s==13)sum+=i;

%ld\n"

sum);

试卷2填空题

从键盘上输入两个正整数,并输入他们的最大公约数。

intgcd(intm,intn)

intr,t;

if(m<

n)

t=m;

m=n;

n=t;

/*$BLANK1$*/

while(n>

0)

r=m%n;

n=r;

}

return(_m);

/*$BLANK2$*/

}

intm,n,result;

Peaseinputtwonumber:

%d%d"

&

m,&

n);

/*$BLANK3$*/

result=gcd(m,n);

result=%d\n"

result);

试卷2程序题

求100~999之间的回文素数之和。

(1)回文素数是一个素数,且从左向右和从右向左读是相同的,如:

101,131,181

(2)要求使用循环实现。

voidPRINT(longs)

s=%ld\n"

s=%ld"

longs=0;

inta,b,I,t;

for(a=1;

a<

=9;

a++)

for(b=0;

b<

b++)

t=101*a+10*b;

for(i=2;

=t/2;

if(t%i==0)break;

if(i>

t/2)s+=t;

参考程序2

for(i=100;

1000;

a=i\100;

b=i\10%10;

c=i%10;

if(a==c)

{for(t=2;

t<

=i/2;

t++)

if(t>

i/2)s+=I;

试卷3改错题

把字符串s中所有数字字符按以下规律改写:

(1)0,1,2,3,4,5,6,7,8分别改写成1,2,3,4,5,6,7,8,9

(2)9改成0

(3)其他字符保持不变

string.h>

chars[80];

getc(s);

/*$ERROR1$*/改为gets(s);

s[i]!

='

\0'

;

i++)

if(s[i]='

9'

)/*$ERROR2$*/改为if(s[i]==’9’)

s[i]='

0'

elseif(s[i]>

&

&

s[i]<

8'

s[i]=s[i]+1;

%c\n"

/*$ERROR3$*/改为printf(“%s\n”,s);

试卷3填空题

定义求n!

的递归函数f(),并调用函数f()求1!

+2!

+3!

+4!

+5!

的值。

longf(intn)

if(n==1||n==0)

return

(1);

else

return(n*f(_n-1);

/*$BLANK1$*/

longs;

s=_0_;

/*$BLANK2$*/

for(i=1;

=5;

s+=f(i);

1!

+2!

+3!

+4!

+5!

=%ld\n"

_s_);

试卷3程序题

计算10000以内9的偶数倍数之和,即:

sum=18+36+54+……9990其中18,36,54^9990等分别是9的2,4,6……1110倍。

voidPRINT(longsum)

sum=%ld\n"

sum=%ld"

inti;

intsum=0;

=1110;

i+=2)

sum*=9;

PRINT(sum);

intI;

for(i=18;

10000;

i+=18)

sum+=i;

参考程序3

if(i%2==0&

i%9==0)sum+=I;

试卷4改错题

若有车的车牌号和罚分记录数据,统计罚分达到或超过12分的车辆总数并输入这些车辆的信息(说明:

id域代表车牌号,score域代表罚分)。

structcar

{charid[12];

intscore;

inti,n=0;

carc[6]={{"

A-QQ111"

8},/*$ERROR1$*/改为structcarc[6]={{“A-QQ111”,8},

{"

A-TT222"

12},

B-WJ333"

C-LC444"

5},

F-PC555"

6},

B-MY666"

12}};

id\tscore\n"

i=0;

6)

if(score>

=12)/*$ERROR2$*/改为if(c[i].score>

=12)

%s\t%d\n"

c[i].id,c[i].score);

n--;

/*$ERROR3$*/改为n++;

n=%d\n"

n);

试卷4填空题

输入所有的“水仙花数”,并输入“水仙花数”的个数。

所谓的“水仙花数”是指一个三位数,其各位数字的立方和等于该数本身。

例如153=1*1*1+5*5*5+3*3*3。

inti,a,b,c,n;

n=___;

for(i=101;

a=i%10;

b=i/10%10;

c=___;

if(a*a*a+b*b*b+c*c*c==i)

%6d"

i);

___;

\nn=%d\n"

试卷4程序题

【三色球问题】

若一个口袋中放有12个球,其中有3个红色的,3个白色的和6个黑色的,从中任取8个球,求共有多少种不同的颜色搭配。

如:

2个白色球和6个黑色球;

1个红色球、3个白色球和4个黑色球;

等都是满足条件的颜色搭配。

voidPRINT(intn)

count=%d\n"

count=%dp"

intn=0;

inta,b,c;

for(a=0;

=3;

for(c=0;

c<

=6;

c++)

if(a+b+c==8)n++;

PRINT(n);

intn=0;

{c=8-a-b;

If(c<

=6)n++;

试卷5改错题

在屏幕上输入以下图形(数字之间没有空格)。

123

45678

9012345

678901234

chara[9]="

"

inti,j,k,n=0;

5;

for(j=0;

j<

i*2+1;

j++)

k=4-i+j;

n=n/10;

/*$ERROR1$*/改为:

n=n%10;

a[k]='

+n;

n++;

9;

%c"

a+j);

/*$ERROR2$*/改为:

printf(“%c”,a[j]);

/n"

/*$ERROR3$*/改为:

printf(“\n”);

试卷5填空题

输入100~300之间个位数码为3的全部素数之和。

voidmain()

s=0;

300;

for(j=2;

if(i%j==0)

break;

/*$BLANK2$*/

if((j>

i/2)&

(i%10==3))

s+=i;

试卷5程序题

已知数列F(n)

当n=1时F(n)=5

当n=(F(n-1)+10/F(n-1)/2

求该数列第五项即F(5)的值。

(1)结果保留五位小数;

voidPRINT(doublef)

F(5)=%.5f\n"

f);

F(5)=%.5f"

doublef=5;

f=(f+10/f)/2;

PRINT(f);

试卷6改错题

将字符串str1和字符串str2合并成一个新字符串str,然后输出字符串str。

charstr1[100],str2[30];

Enterthefirststring:

"

gets(str1);

Enterthesecondstring:

gets(str2);

str1[i]!

;

i++);

while(str2[j]!

='

str1[i++]=str2[j];

j++;

str1[i]="

\0"

/*$ERROR2$*/改为:

str[j]=’\0’;

str1);

printf(“%s\n”,str);

试卷6填空题

输入10个数据,计算并输入其中所有正数的平均值。

#defineN10

voidmain()

doubleave=0,a[N],*p;

p=a;

/*$BLANK1$*/

while(p<

a+N)

{

%lf"

p);

if(*p>

0)/*$BLANK2$*/

ave+=*p;

p++;

if(n>

ave/=n;

/*$BLANK3$*/

ave=%lf\n"

ave);

elseprintf("

Notexistpositivenumber\n"

试卷6程序题

求满足下列条件的三位数之和。

条件如下:

(1)各位数字只能从5、6、7、8中选;

(2)各位数字互不相同。

longs=0;

for(a=5;

=8;

for(b=5;

for(c=5;

if(a!

=b&

a!

=c&

c!

=b)s+=100*a+10*b+c;

试卷7改错题

下面程序通过指针操作,输入由二进制数字组成的字符串“0010110101000001”对应的无符号十进制整数。

charv2[]="

0010110101000001"

*p;

unsignedintv10,t;

v10=1;

p=v2[0];

while(*p!

t=*p-'

v10=v10*2+t;

p--;

\n%sisconveredtointegernumber:

%u\n"

v2,v10);

试卷7填空题

下列程序的功能是计算并输出给定整数n的所有因子之和(不包括1和它自身)。

规定n的值不大于1000.

intn,i,s;

Pleaseinputn:

%d"

___);

s___;

for(i=2;

i<

=n-1;

if(n%i==0)

s=s+___;

试卷7程序题

已知三角形的三条边长分别为a、b和c,且满足下列条件:

(1)边长为小于等于100的正整数;

(2)边长a小于b;

(3)A*a+b*b==c*c。

统计满足上述条件的三角形的个数。

math.h>

n=%d%%d"

=100;

for(b=a+1;

for

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2