文件编程题救急:6 | 您所在的位置:网站首页 › 24个大写英文字母语音读出来 › 文件编程题救急:6 |
6-1首字母大写
从一个文件中读取一篇英文文章,请将文章中所有单词首字母大写并存入另一个文件中。“单词”是指一串连续的字母。 函数接口定义: void CapitalizeTheFirstLetter(FILE *in, FILE *out);说明:参数 in 和 out 为指示两个文件的指针。函数从 in 所指文件中的读出数据,将结果写入 out 所指的文件中。 裁判测试程序样例: #include #include #include void CapitalizeTheFirstLetter(FILE* in, FILE* out); int main() { FILE* in, * out; in = fopen("in.txt", "r"); out = fopen("out.txt", "w"); if (in && out) { CapitalizeTheFirstLetter(in, out); } else { puts("文件无法打开!"); } if (in) { fclose(in); } if (out) { fclose(out); puts("文件保存成功!"); } return 0; } /* 请在这里填写答案 */ 输入样例: Spring Morning translated by Xu Yuanchong This spring morning in bed I am lying, not awake till birds are crying. After one night of wind and showers, how many are the fallen flowers. 输出样例:程序运行结束后,打开“out.txt”文件,查看文件内容。 Spring Morning Translated By Xu Yuanchong This Spring Morning In Bed I Am Lying, Not Awake Till Birds Are Crying. After One Night Of Wind And Showers, How Many Are The Fallen Flowers.代码长度限制 16 KB 时间限制 400 ms 内存限制 64 MB 解题代码 void CapitalizeTheFirstLetter(FILE* in, FILE* out) { char ch; int flag = 0; while ((ch = fgetc(in)) != EOF) { if (flag == 0 && (ch >= 'a' && ch = 'A' && ch = 'a' && ch = 'A' && ch |
CopyRight 2018-2019 实验室设备网 版权所有 |