77范文网 - 专业文章范例文档资料分享平台

C语言参考答案(2)

来源:网络收集 时间:2018-12-29 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

for(y=0;y

{if(x[y]>i) {i=x[y];p0=&x[y];}

else if(x[y]

{j=x[y];p1=&x[y];}}

t=*p0;*p0=x[n-1];x[n-1]=t; t=*p1;*p1=x[0];x[0]=t; return; } main()

{int a[10],u,*r; for(u=0;u<10;u++) scanf(\f(a,10);

for(u=0,r=a;u<10;u++,r++) printf(\printf(\

有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串。

#include\#define N 10 main()

{char a[N+1],b[N+1],*p,*q; int m; gets(a);

scanf(\p=a+m;q=b; strcpy(q,p); puts(q);}

从键盘输入一个字符串,将其中的小写字母全部转换成大写字母,然后输出到一个磁盘文件“test”中保存。输入的字符串以“!”结束。 解:#include main() { File *fp; Char str[100]; Int I=0;

If((fp=fopen(“test”,”w”)==NULL) {printf(“Can not open the file\\n”); exit(0); }

printf(“Input a string:\\n”); gets(str);

while(str[i]!=’!’)

{if (str[i]>=’a’&&str[i]<=’z’) str[i]=str[I-32]; fputc(str[i],fp); I++; } fclose(fp);

fp=fopen(“test”,”r”); fgets(str,strlen(str)+1,fp); printf(“%s\\n”,str); fclose(fp); }

从键盘输入若干行字符(每行长度不等),输入后把它们存储到一磁盘文件中。再从该文件中读入这些数据,将其中小写字母转换成大写字母后在显示屏上输出。 解: #include main() {int I,flag; char str[80],c; FILE *fp;

Fp=fopen(“text”,”w”); Flag=1;

While(flag==1)

{printf(“\\n Input string:\\n”); ges(str);

fprintf(fp,”%s”,str); printf(“\\nContinue?”); c=getchar();

if((c==’N’)||(c==’n’)) flag=0; getchar();} fcolse()fp;

fp=fopen(“text”,”r”);

while(fscanf(fp,”%s”,str)!=EOF) {for(I=0;str[i]!=’\\0’;I++)

if((str[i]>=’a’)&& (str[i]<=’z’)) str[i]-=32; printf(“\\n%s\\n”,str); } fclose(fp); }

编写一个递归函数计算n!,主函数读入正整数n并输出计算结果。 #include \int fact1(int n)??

{?? if(n==1||n==0) return 1;?? else return n*fact1(n-1);??}?? int fact2(int n)??

{?? int i,t=1;?? for(i=1;i<=n;i++)?? t*=i;?? return t;??}?? void main()??

{intn;??scanf(\

printf(\ printf(\用递归法讲一个整数n转换成字符串。例如,输入483,应输出字符串“483”。n的位数不确定,可

以使任意位数

#include void main() {

void exchange(int n); int n;

printf(\输入一个整数\\n\\n\ scanf(\

printf(\输出是:\\n\\n\ if(n<0) {

putchar('-'); n=-n; }

exchange(n); printf(\}

void exchange(int n) { int i;

if((i=n/10)!=0) exchange(i); putchar(n+'0'); }

要不要“学雷锋”

Depicted by the cartoon is an ironic scenario that a group of citizens, glancing at an aged grandpa falling down to the ground and a blind man groping forward, hide themselves behind the statue of Leifeng, avoiding offering help and fearing of getting into troubles. The cartoonist reminds them as well as all of us that mutual assistance is the right access towards a harmonious world. / never easily let go of the virtue of mutual assistance.

Never easily let go off the simple truth, “a harmonious society is always based on the prevalence of mutual assistance.” However, cases against this principle are abundant! Such an incident has ever been covered by TV media: regardless of his time lost and money cost, a driver took an injured granny to a hospital, only to be mistakenly accused as the trouble maker. After that, the population who are willing to offer help decreased to one fifth of those five years ago, according to a report from CCTV. The follow two factors may account for this trend. A conventional wisdom dissuades people from offering help that showing support is nothing else than getting into troubles. More than anything, the enthusiasm of helping others is now suppressed by the lack of interpersonal trust!

How to step out of the shadow? It occurs to many that role-models should be set up to encourage citizens to offer help! But is this method effective enough to put an end to this delinquency? What is really urgent is to rebuild nutual-trust among the public and to eliminate the widly-spread fear that they might be “wronged”, but how? Of course, it requires the joint-effort from the general public and social researcher alike.

《如此失“信”》

Under

the ridiculous appearance of the cartoon lies a scene full of sorrow and regret: stealing the precious “coin” beneath the Chinese character “trust”, a greedy man is breaking his credibility only to set more barriers to his long-term development! The author of the cartoon adopts this metaphor to warn him, as well as all of us, that we can withstand anything but the breach of trust.

Actually, conceived in this cartoon is simple truth: the most valuable treasure is not anything else but credibility that cannot afford any destruction. However, cases against this principle are abundant and within easy reach. In commercial world, it is not surprising to see, for huge profits, some businesses offering their customers substandard commodities and services, inferior to what the promised. Similarly, in the academic society, it is even not uncommon to find some “scholars” commit plagiarism for promotion or for enhancing their fame. Consequently, they are trapped into a difficult situation: sacrifice long-term benefit for instant satisfaction. More than anything, they disturb the normal atmosphere of both the business world and academy groups.

How to put an end to this social delinquency? A package deal, involving governmental intervention and regulation-based restrictions, may be welcomed by most of us. But is that comprehensive enough to put an end to this delinquency? Actually, that is merely a passive way! What we really need is some innermost changes, self-discipline for one. If there were general awareness that “honesty is the

actual source of social achievement and we can never bypass this virtue for direct short term benefits”, this delinquency would be put to an end. 《家乡“变化”》

Have you ever noticed the “great changes” of your hometown? If you have, you may sense the same regret and sorrow as the retired man does in the pictures. A newly-built bridge over the river attracts the attention of him and spurs his excitement. However, leaning against the bridge, he finds no water flowing in the river.

The author of the cartoon, through the sight of the aged man, is imparting us the notion that never sacrifice ecological balance for economic benefits. Admittedly, economic development labels the advancement of society! However, never place too much emphasis on it, or we may go to an extreme! Any cases? Sure! Haven’t you ever noticed that chimneys brought big bucks to enterprises but big troubles to the general public, foggy air for one? Haven’t you ever found that urbanization offers people more houses but less comfort? Why are we so zealous of “destroying our surroundings”? Aren’t we doing so to exhibit our “achievements” of civil construction?

At the end of the day, we have to find a way out! Only with the combination of transforming of economic planning, guiding from experts, and supervising from the general public, can the situation turn optimistic! Currently, department concerned, aided by experts, are working forcefully to boost the green-economy. However, if there were also effective supervision from the general public, which requires assistance from the mass media, economic construction would go green and reasonable.

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库C语言参考答案(2)在线全文阅读。

C语言参考答案(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/398228.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: