#include#include #include #include using namespace std;int main(){string filename;cout << "输入打开的文件: ";cin >> filename;ofstream fout;fout.open(filename,ios_base::app);if(!fout.is_open()){cerr << "fail to open " << filename << endl;system("pause");exit(0);}fout << endl << "merge successfully" << endl;return 0;}
#include#include #include using namespace std;int main(){int i = 0, zifu = 0, danci = 0, hangshu = 1;char ch;char s[100];string filename;ifstream file;cout << "输入要统计的英文文本文件名:";cin >> filename;file.open(filename);while ((ch = file.get()) != EOF){s[i] = ch;if (ch != '\n')zifu += 1;else if (ch == '\n')hangshu += 1;i++;}for (i = 0; i < 100; i++){if (s[i] != ' '&&s[i] != ','&&s[i]!='.'&&s[i + 1] == ' ')danci += 1;else if (s[i] != ' '&&s[i] != '.'&&s[i] != ','&&s[i + 1] == '.')danci += 1;else if (s[i] != ','&&s[i] != ' '&&s[i]!='.'&&s[i + 1] == ',')danci += 1;}cout << "字符数:" << zifu << endl;cout << "单词数:" << danci << endl;cout << "行数:" << hangshu << endl;system("pause");return 0;}