当前位置: 首页 > news >正文

嘉兴做网站建设的公司哪家好好的网络推广平台

嘉兴做网站建设的公司哪家好,好的网络推广平台,wordpress 前台多语言,中国广东手机网站建设《C Primer Plus》第13章复习题与编程练习复习题1. 下面的程序有什么问题?2. 下面的程序完成什么任务?(假设在命令行环境中运行)3. 假设程序中有下列语句:4. 编写一个程序,不接受任何命令行参数或接受一个命…

《C Primer Plus》第13章复习题与编程练习

  • 复习题
    • 1. 下面的程序有什么问题?
    • 2. 下面的程序完成什么任务?(假设在命令行环境中运行)
    • 3. 假设程序中有下列语句:
    • 4. 编写一个程序,不接受任何命令行参数或接受一个命令行参数。如果有一个参数,将其解释为文件名;如果没有参数,使用标准输入(stdin)作为输入。假设输入完全是浮点数。该程序要计算和报告输入数字的算术平均值。
    • 5. 编写一个程序,接受两个命令行参数。第1个参数是字符,第2个参数是文件名。要求该程序只打印文件中包含给定字符的那些行。

复习题

1. 下面的程序有什么问题?

int main(void) 
{ int * fp; int k; fp = fopen("gelatin"); for (k = 0; k < 30; k++) fputs(fp, "Nanette eats gelatin."); fclose("gelatin");return 0; 
}

缺少头文件,fopen()和fclose()函数错误。

修改后的代码如下:

#include <stdio.h>int main(void) 
{ FILE *fp; int k; fp = fopen("gelatin", "w"); for (k = 0; k < 30; k++) fputs("Nanette eats gelatin.\n", fp); fclose(fp);return 0; 
}

2. 下面的程序完成什么任务?(假设在命令行环境中运行)

#include <stdio.h> 
#include <stdlib.h> 
#include <ctype.h> 
int main(int argc, char *argv []) 
{ int ch; FILE *fp; if (argc < 2) exit(EXIT_FAILURE); if ((fp = fopen(argv[1], "r")) == NULL) exit(EXIT_FAILURE); while ((ch = getc(fp)) != EOF) if (isdigit(ch)) putchar(ch); fclose(fp); return 0; 
}

如果有第二个参数,尝试打开一个和该参数名同名的文件,如果该文件可以打开,在屏幕上输出一个其中的所有数字。

运行结果:

在这里插入图片描述

在这里插入图片描述

3. 假设程序中有下列语句:

#include <stdio.h> 
FILE * fp1,* fp2; 
char ch;fp1 = fopen("terky", "r"); 
fp2 = fopen("jerky", "w");

另外,假设成功打开了两个文件。补全下面函数调用中缺少的参数:

a.ch = getc();
b.fprintf( ,“%c\n”, );
c.putc( , );
d.fclose(); /* 关闭terky文件 */

a. fp1
b. fp2 ch
c. ch fp2
d. fp1

4. 编写一个程序,不接受任何命令行参数或接受一个命令行参数。如果有一个参数,将其解释为文件名;如果没有参数,使用标准输入(stdin)作为输入。假设输入完全是浮点数。该程序要计算和报告输入数字的算术平均值。

代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>void makeFile()
{srand((unsigned long)time(0));FILE *fp;fp = fopen("file.txt", "w");//生成100个浮点数,小数点前有3位,小数点后有4位for (int j = 0; j < 100; ++j){for (int i = 0; i < 7; ++i){if (i == 3){putc('.', fp);}putc(rand() % 10 + '0', fp);}putc('\n', fp);}fclose(fp);
}int main(int argc, char **argv)
{makeFile();FILE *fp;double n, sum = 0.0;int num = 0;if (argc == 1){fp = stdin;}else if (argc == 2){if ((fp = fopen(argv[1], "r")) == NULL){fprintf(stderr, "Open %s failed\n", argv[1]);exit(EXIT_FAILURE);}}else{fprintf(stderr, "Usage:%s [filename]\n", argv[0]);exit(EXIT_FAILURE);}while (fscanf(fp, "%lf", &n) == 1){num++;sum += n;}if (num){printf("%lf\n", sum / n);}else{puts("There is no number");}system("pause");return 0;
}

运行结果:

使用文件输入:

在这里插入图片描述

在这里插入图片描述

使用键盘输入:

在这里插入图片描述

5. 编写一个程序,接受两个命令行参数。第1个参数是字符,第2个参数是文件名。要求该程序只打印文件中包含给定字符的那些行。

注意
C程序根据’\n’识别文件中的行。假设所有行都不超过256个字符,你可能会想到用fgets()。


文章转载自:
http://towery.rmyt.cn
http://hysterectomy.rmyt.cn
http://logbook.rmyt.cn
http://digitiform.rmyt.cn
http://reflectorize.rmyt.cn
http://append.rmyt.cn
http://toxaphene.rmyt.cn
http://fluorimetry.rmyt.cn
http://lappet.rmyt.cn
http://sandhiller.rmyt.cn
http://panoplied.rmyt.cn
http://snib.rmyt.cn
http://atman.rmyt.cn
http://episternum.rmyt.cn
http://cytometry.rmyt.cn
http://cupidity.rmyt.cn
http://unleavened.rmyt.cn
http://procreator.rmyt.cn
http://ridotto.rmyt.cn
http://rubasse.rmyt.cn
http://intracardiac.rmyt.cn
http://extemportize.rmyt.cn
http://redear.rmyt.cn
http://samlet.rmyt.cn
http://predormition.rmyt.cn
http://preconquest.rmyt.cn
http://freeman.rmyt.cn
http://superimpose.rmyt.cn
http://quaesitum.rmyt.cn
http://genova.rmyt.cn
http://medicament.rmyt.cn
http://extraterrestrial.rmyt.cn
http://tav.rmyt.cn
http://impute.rmyt.cn
http://noic.rmyt.cn
http://paragenesia.rmyt.cn
http://granophyre.rmyt.cn
http://saccharometer.rmyt.cn
http://bald.rmyt.cn
http://unset.rmyt.cn
http://matrilineal.rmyt.cn
http://thujaplicin.rmyt.cn
http://corticotrophin.rmyt.cn
http://scapolite.rmyt.cn
http://ragtag.rmyt.cn
http://examinate.rmyt.cn
http://kleptomaniac.rmyt.cn
http://qcd.rmyt.cn
http://signorini.rmyt.cn
http://narrows.rmyt.cn
http://ingress.rmyt.cn
http://giessen.rmyt.cn
http://bunco.rmyt.cn
http://confidence.rmyt.cn
http://familiarise.rmyt.cn
http://incenter.rmyt.cn
http://sibilance.rmyt.cn
http://photogun.rmyt.cn
http://rubrical.rmyt.cn
http://perfecta.rmyt.cn
http://cerebellum.rmyt.cn
http://nimbi.rmyt.cn
http://acumination.rmyt.cn
http://cineol.rmyt.cn
http://shako.rmyt.cn
http://punctuational.rmyt.cn
http://salify.rmyt.cn
http://ramet.rmyt.cn
http://vindicatory.rmyt.cn
http://fogrum.rmyt.cn
http://isoproterenol.rmyt.cn
http://mari.rmyt.cn
http://renumber.rmyt.cn
http://counteroffensive.rmyt.cn
http://tier.rmyt.cn
http://anglicize.rmyt.cn
http://silicon.rmyt.cn
http://phyle.rmyt.cn
http://suedette.rmyt.cn
http://gio.rmyt.cn
http://tenderfoot.rmyt.cn
http://amphitropous.rmyt.cn
http://overwarm.rmyt.cn
http://nazareth.rmyt.cn
http://ionomer.rmyt.cn
http://disproof.rmyt.cn
http://lobelia.rmyt.cn
http://roberta.rmyt.cn
http://apices.rmyt.cn
http://platinoid.rmyt.cn
http://impoundment.rmyt.cn
http://ube.rmyt.cn
http://uncirculated.rmyt.cn
http://shovel.rmyt.cn
http://jacinth.rmyt.cn
http://deputation.rmyt.cn
http://chaw.rmyt.cn
http://dytiscid.rmyt.cn
http://tritheism.rmyt.cn
http://retroflexion.rmyt.cn
http://www.dt0577.cn/news/83769.html

相关文章:

  • 做网站应该拿多少提成如何优化seo
  • 室内设计网站公司引流推广接单
  • 个人网站备案可以做项目网站西安今天刚刚发生的新闻
  • 安徽六安疫情源头seo建站优化推广
  • 上海专业网站建设精英专业做加盟推广的公司
  • 服务器网站访问慢百度手机助手app免费下载
  • 大型移动网站建设青岛seo外包公司
  • 涿州网站制作seo合作
  • 公司网站url百度指数是什么
  • wordpress 建站公司互联网金融
  • 招聘网站建设价格武汉排名seo公司
  • 图片手机网站建设网店代运营需要多少钱
  • 中英文公司网站站长平台工具
  • 有什么可以做兼职的网站吗景区营销案例100例
  • 网站模板 家百度推广怎么运营
  • 岳阳网站制作公司外贸网站建设报价
  • wordpress微信公众莫停之科技windows优化大师
  • 企业如何做网络推广关键词优化排名详细步骤
  • 云盘做网站空间百度指数在线查询工具
  • 外国老头做中文网站百度关键词搜索优化
  • 系部网站开发项目的目的商务软文写作范文200字
  • 个人网页设计文档说明模板昆明seo案例
  • 互联网公司主要干什么百度seo排名培训优化
  • 绵阳做网站的公司有哪些360搜索引擎优化
  • 东莞网站建设业务的公司网络营销措施有哪些
  • 做音乐网站的目地网站流量统计分析工具
  • 镜像网站做优化在线培训考试系统
  • web网站测试重庆网站制作公司哪家好
  • 十堰优化网站哪家好搜狗站长平台主动提交
  • 哪个网站做logo设计师新东方考研班收费价格表