版本比较
智?文章生成器
正文
增加 100 行删除 138 行
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159# 智?文章生成器~~不会有人用吧……~~效果:html https://yuanbao.tencent.com/sc/CTL5nWhPKC5tGMX```cpp#include <iostream>#include <string>#include <ctime>#include <windows.h>using namespace std;string x[48] = {"ga","gu","we","ci","en","mo","no","ack","fot","qi","qak","bon","ba","due","ero","ewen","ev","eq","gi","hi","her","in","iel","jor","kur","ka","la","lim","man","oker","por","qiu","qwen","rea","sti","se","top","te","usl","ur","ve","van","wick","xin","xy","yun","zon","zel"};inline string makeword(){string ans;int r = 1 + rand() % 4;for (int i = 0; i < r; ++i){ans += x[rand() % 48];}return ans;}int stn_sm, stn_bg;int sm, bg;inline void makearticle(int s, int l){srand(time(0));int n = s + rand() %(l - s + 1);char lst = '.';for (int i = 0; i < n; ++i){int m = 1 + rand() % 6;string a = makeword();if(lst != ','){a[0] ^= ' ';}cout << a;for (int j = 0; j < m; ++j){a = makeword();cout << ' ' << a;}int f;//.!?,if (i ==(n - 1)){f = rand() % 3;}else{f = rand() % 11;}switch (f){case 0 : lst = '.';break;case 1 : lst = '!';break;case 2 : lst = '?';break;default : lst = ',';break;}cout << lst << ' ';}return;}int main() {// 设置控制台编码为UTF-8SetConsoleOutputCP(CP_UTF8);SetConsoleCP(CP_UTF8);// 调整生成文章初始的参数stn_sm = 30;//最少生成多少句话stn_bg = 50;//最多生成多少句话// 以下为生成代码,请勿修改sm = stn_sm;bg = stn_bg;while (1){makearticle(sm, bg);cout << "\n\n----------------------------\n\n";char c;try{cout<< "是否再生成一篇文章?( y/n )\n> ";cin >> c;if (!((c == 'y') ||(c == 'Y'))){break;}cout<< "参数-最少生成多少句话?( 输入不小于0的数, 最大100000, 输入0表示使用默认配置 " << stn_sm << " )\n> ";cin >> sm;if (!((sm > 0) &&(sm <= 100000))){sm = stn_sm;}cout<< "\n参数-最多生成多少句话?( 输入不小于0的数, 最大100000, 输入0表示使用默认配置 " << stn_bg << " )\n> ";cin >> bg;if (!((bg > 0) &&(bg <= 100000))){bg = stn_bg;}cout << "\n\n----------------------------\n\n";}catch (const char * msg){break;}}system("pause");return 0;}```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121# 智?文章生成器~~不会有人用吧……~~效果:```cpp#include <ctime>#include <iostream>#include <string>using namespace std;// 单个辅音字母const string cons = "bcdfghjklmnpqrstvwxyz";// 单个元音字母const string vows = "aeiouy";// 随机取一个辅音inline char randCons() { return cons[rand() % cons.size()]; }// 随机取一个元音inline char randVowel() { return vows[rand() % vows.size()]; }// 生成单词:辅音开头,辅音结尾,严格交替inline string makeword(){string w;int len = 3 + rand() % 6; // 单词长度 3~8 个字母for (int i = 0; i < len; ++i) {if (i % 2 == 0) {w += randCons(); // 偶数位:辅音}else {w += randVowel(); // 奇数位:元音}}// 强制以辅音结尾if (vows.find(w.back()) != string::npos) {w.back() = randCons();}return w;}int stn_sm, stn_bg;int sm, bg;inline void makearticle(int s, int l){srand(time(0));int n = s + rand() % (l - s + 1);char lst = '.';for (int i = 0; i < n; ++i) {int m = 1 + rand() % 6;string a = makeword();if (lst != ',')a[0] = toupper(a[0]);cout << a;for (int j = 1; j < m; ++j) {cout << ' ' << makeword();}int f = (i == n - 1) ? rand() % 3 : rand() % 11;switch (f) {case 0:lst = '.';break;case 1:lst = '!';break;case 2:lst = '?';break;default:lst = ',';break;}cout << lst << ' ';}}int main(){stn_sm = 30;stn_bg = 50;sm = stn_sm;bg = stn_bg;while (1) {makearticle(sm, bg);cout << "\n\n----------------------------\n\n";char c;cout << "是否再生成一篇文章?( y/n )\n> ";cin >> c;if (!(c == 'y' || c == 'Y'))break;cout << "参数-最少生成多少句话?( 0 使用默认 " << stn_sm << " )\n> ";cin >> sm;if (!(sm > 0 && sm <= 100000))sm = stn_sm;cout << "\n参数-最多生成多少句话?( 0 使用默认 " << stn_bg << " )\n> ";cin >> bg;if (!(bg > 0 && bg <= 100000))bg = stn_bg;cout << "\n\n----------------------------\n\n";}system("pause");return 0;}```