大学经典C语言编程试的题目Word格式.docx

上传人:b****5 文档编号:15851782 上传时间:2022-11-16 格式:DOCX 页数:75 大小:33.90KB
下载 相关 举报
大学经典C语言编程试的题目Word格式.docx_第1页
第1页 / 共75页
大学经典C语言编程试的题目Word格式.docx_第2页
第2页 / 共75页
大学经典C语言编程试的题目Word格式.docx_第3页
第3页 / 共75页
大学经典C语言编程试的题目Word格式.docx_第4页
第4页 / 共75页
大学经典C语言编程试的题目Word格式.docx_第5页
第5页 / 共75页
点击查看更多>>
下载资源
资源描述

大学经典C语言编程试的题目Word格式.docx

《大学经典C语言编程试的题目Word格式.docx》由会员分享,可在线阅读,更多相关《大学经典C语言编程试的题目Word格式.docx(75页珍藏版)》请在冰豆网上搜索。

大学经典C语言编程试的题目Word格式.docx

inthcf(intu,intv)

intt,r;

if(v>

u)

{t=u;

u=v;

v=t;

while((r=u%v)!

=0)

{u=v;

v=r;

return(v);

intlcd(intu,intv,inth)

return(u*v/h);

2.输入一行字符,分别统计出其中字母、空格、数字和其他字符的个数。

intletter,digit,space,others;

voidcount(char[]);

chartext[80];

Pleaseinputstring:

gets(text);

string:

puts(text);

letter=0;

digit=0;

space=0;

others=0;

count(text);

letter:

%d,digit:

%d,space:

%d,others:

%d\n"

letter,digit,space,others);

voidcount(charstr[])

inti;

for(i=0;

str[i]!

='

\0'

;

i++)

if((str[i]>

a'

&

str[i]<

z'

)||(str[i]>

A'

Z'

))

letter++;

elseif(str[i]>

0'

9'

digit++;

elseif(str[i]==32)

space++;

else

others++;

3.输入一个正整数求出它是几位数;

输出原数和位数。

intdigit;

Pleaseinputnumbers:

Numbers:

digit:

digit);

if(str[i]>

4.输入一个正整数,输出原数并逆序打印出各位数字。

voidinvertLongInt(long);

unsignedlongiNumber;

Pleaseinputanumber:

%ld"

iNumber);

Theinputnumberis:

%ld\n"

iNumber);

Theinversenumberis:

"

invertLongInt(iNumber);

voidinvertLongInt(longx)

if(x>

=0&

x<

=9)

x);

{

%d"

x%10);

invertLongInt(x/10);

}

5.从键盘上输入若干学生的一门课成绩,统计并输出最高成绩和最低成绩及相应的序号,当输入负数时结束输入。

6.从键盘上输入若干学生的一门课成绩,计算出平均分,当输入负数时结束输入。

将结果输出。

7.求1!

+2!

+3!

+……+20!

,将结果输出。

floats=0,t=1;

intn;

for(n=1;

n<

=20;

n++)

t=t*n;

s=s+t;

1!

=%e\n"

s);

8.打印以下图案:

*

***

*****

*******

inti,j;

Thepictureis:

staticcharpicture[4][7]={{'

'

'

*'

},

{'

},{'

*'

}};

i<

=3;

for(j=0;

j<

=6;

j++)

%c"

picture[i][j]);

9.打印以下图案:

*

**

***

****

charpicture[4][4]={{'

10.求下列试子的值:

1-1/2+1/3-1/4+……+1/99-1/100,将结果输出。

floatsum=1.0,t,s=1;

for(i=1;

=100;

t=s/i;

sum=sum+t;

s=-s;

1-1/2+1/3-1/4+……+1/99-1/100=%5.4f\n"

sum);

11.打印出100~999之间的所有水仙花数。

inti,j,k,n;

100~999之间的所有水仙花数are:

for(n=100;

1000;

i=n/100;

j=n/10-i*10;

k=n%10;

if(n==i*i*i+j*j*j+k*k*k)

%d"

n);

12.求Sn=a+aa+aaa+…+aa…a之值,n,a由键盘输入。

inta,n,i=1,sn=0,tn=0;

a,n=:

a,&

n);

while(i<

=n)

tn=tn+a;

sn=sn+tn;

a=a*10;

++i;

a+aa+aaa+…+aa…a=%d\n"

sn);

13.打印以下图案:

#include<

chara[7]={'

};

inti,j,k;

charspace='

4;

"

for(j=1;

=i;

space);

for(k=0;

k<

7;

k++)

a[k]);

14.打印以下图案:

1

121

12321

1234321

15.打印以下图案:

16.编写一个统计学生成绩程序,完成以下功能:

输入4个学生的2门课成绩;

求出全班的总平均分,将结果输出。

#defineN4

structstudent

charnum[3];

charname[4];

floatscore[2];

floatavr;

stu[N];

floatsum,average;

N;

i++)/*输入数据*/

inputscoresofstudent%d:

i+1);

name:

%s"

stu[i].name);

2;

score%d:

j+1);

%f"

stu[i].score[j]);

average=0;

/*计算*/

sum=0;

sum+=stu[i].score[j];

stu[i].avr=sum/2;

average+=stu[i].avr;

average/=N;

Namescore1score2average\n"

%5s%10s"

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

%9.2f"

stu[i].score[j]);

%8.2f\n"

stu[i].avr);

average=%5.2f\n"

average);

17.打印以下图案:

chara[5]={'

5;

j

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

当前位置:首页 > 经管营销 > 人力资源管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1