为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

计算所有字符、非空白字符、字母的总数

2018-02-18 3页 doc 14KB 12阅读

用户头像

is_358746

暂无简介

举报
计算所有字符、非空白字符、字母的总数计算所有字符、非空白字符、字母的总数 //录入文本文件,计算所有字符、非空白字符、字母的总数 //将这些数字打印到屏幕并写入另一文件 #include #include #include #include #include using namespace std; int main() { char in_file_name[21],out_file_name[21]; ifstream fin; ofstream fout; cout>in_file_name; cout>out_fi...
计算所有字符、非空白字符、字母的总数
计算所有字符、非空白字符、字母的总数 //录入文本文件,计算所有字符、非空白字符、字母的总数 //将这些数字打印到屏幕并写入另一文件 #include #include #include #include #include using namespace std; int main() { char in_file_name[21],out_file_name[21]; ifstream fin; ofstream fout; cout<<"I will entering all character from an input file\n" <<"and count the number about character、non-blank character\n" <<"and letter\n" <<"then write them to an output file"; cout<<"enter the input file name\n"; cin>>in_file_name; cout<<"enter the output file name\n"; cin>>out_file_name; fin.open(in_file_name); if(fin.fail()) { cout<<"input file opening fail\n"; exit(1); } fout.open(out_file_name); if(fout.fail()) { cout<<"output file opening fail\n"; exit(1); } char next; int letter,nbcha,character;//nbcha为非空白字符 letter=0; nbcha=0; character=0; fin.get(next); while(!fin.eof()) { character++; if(isalpha(next)) letter++; else if(!isspace(next)) nbcha++; fin.get(next); } cout<<"the character is "<
/
本文档为【计算所有字符、非空白字符、字母的总数】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索