- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
1、某养鸡场现有50只鸡,按繁殖每年增长50%计算,多少年后鸡场的鸡总数超过500只?
#include
main int n;
float x;
n 1;
x 50;
while x 500 x x* 1+0.5 ;
n n+1; printf 经过%d年可以达到500只。\n,n ; 2、求数组a[10] 20,10,11,53,21,2,9,104,33,24 中偶数之和。
#include
main int a[10] 20,10,11,53,21,2,9,104,33,24 ;
int sum,i;
sum 0;
for i 0;i 10;i++ if a[i]%2 0 sum sum+a[i]; printf 数组中的偶数和为%d。\n,sum ; 3、求数组a[10] 20,10,11,53,21,2,9,104,33,24 中最大数、最小数及其总和。
#include
main int a[10] 20,10,11,53,21,2,9,104,33,24 ;
int sum,max,min,i;
sum 0;
max a[0];
min a[0];
for i 0;i 10;i++ if a[i] max max a[i];
if a[i] min min a[i];
sum sum+a[i]; printf 数组中的最大数为%d。\n,max ;
printf 数组中的最小数为%d。\n,min ;
printf 数组中的数的和为%d。\n,sum ; 4、统计test.txt文件中所包含的字母的个数。
(说明:test.txt文件由读者事先创建并输入一些字符)
#include
#include
main FILE *fp;
int n;
char ch;
n 0;
if fp fopen test.txt,r NULL printf file open error!\n ;
exit 0 ; else printf File open is ok!\n ;
while ch fgetc fp ! EOF if ch A ch Z n++; if ch a ch z n++; fclose fp ;
printf 文件中字母的个数是%d。\n,n ; 5、将test.txt文件中的内容添加到hello.txt文件的末尾。
(说明:test.txt和hello.txt文件由读者事先创建并输入一些字符)
#include
#include
main FILE *fp1,*fp2;
char ch;
if fp1 fopen test.txt,r NULL printf file open error!\n ;
exit 0 ; else printf File open is ok!\n ;
if fp2 fopen hello.txt,w NULL printf file open error!\n ;
exit 0 ; else while ch fgetc fp1 ! EOF fputc ch,fp2 ; fclose fp1 ;
fclose fp2 ; 6、输入整数n,输出菱形图案。当n 5时的菱形图案如下图所示。 * *** ***** ******* *********
*******
*****
***
*
#include
main int i,j,n;
printf Input number n:\n ;
scanf %d,n ;
for i 1;i n;i++ for j 5-i;j 1;j-- printf ;
for j 1;j 2*i-1;j++ printf * ;
printf \n ; for i n-1;i 1;i-- for j 1;j n-i;j++ printf ;
for j 1;j 2*i-1;j++ printf * ;
printf \n ; 7、输入三角形的三边长,求三角形的面积,调用函数Area(a,b,c)实现。
#include
#include
main int a,b,c;
float s;
printf 请输入三条边a,b,c:\n ;
scanf %d%d%d,a,b,c ;
s area a,b,c ;
printf 三角形的面积为%f,s ; float area int a,int b,int c float p,s;
p a+b+c /2;
s sqrt p* p-a * p-b * p-c ;
ret
您可能关注的文档
- (9月最新修订)2011全国各地中考语文试题分类汇编专题:辨析并修改病句含答案.doc
- (word版,案扫描)福建福州市2015年中考题.doc
- (教育部权威版2014年全国各省市区毕业生回生源地派遣单位一览表.doc
- (解析版)203年中考物理试题分类汇编--电热综合.doc
- (精编)201广州中考语文试题及答案.doc
- (人教版)小学文一年级(下册)生字表(制作卡片).doc
- (新编资料)213-2014学年高中数学 3.2.1《古典概型》导学案 新人教A版必修3.doc
- (一年级下册)字.doc
- (粤教版)《项本纪》新学案.doc
- [外研版(必修)]Module 2 No Drugs教案.doc
文档评论(0)