## 题目1：全量字符串的剩余

#include <iostream>#include <vector>#include <string>using namespace std;//切出来：和，之间的数字int findNum(string str, int n){ int res = 0; while ((n++) && (n<str.size())) { if (str[n] == ':') continue; if (str[n] == ',') break; if (str[n] == '@') break; if (str[n] >= '0'&&str[n] <= '9') res = res * 10 + (str[n] - '0'); } return res;}//计算的主程序string getResult(string str){ vector<char> qlzifu; vector<int> qlzfnum; vector<char> zyzifu; int i = 0; string res1 = ""; for (; i < str.size(); i++) { if (str[i] == '@') { break; } if ((str[i] >= 'a'&&str[i] <= 'z') || (str[i] >= 'A'&&str[i] <= 'Z')) { qlzifu.push_back(str[i]); } if (str[i] == ':') qlzfnum.push_back(findNum(str, i)); } int numalpha = qlzifu.size(); vector<int> zyzfnum; //处理已占用字符串 if (i != str.size() - 1) { for (; i < str.size(); i++) { if ((str[i] >= 'a'&&str[i] <= 'z') || (str[i] >= 'A'&&str[i] <= 'Z')) { zyzifu.push_back(str[i]); } if (str[i] == ':') zyzfnum.push_back(findNum(str, i)); } } //补充零 int qianque = qlzifu.size() - zyzfnum.size(); while (qianque--) { zyzfnum.push_back(0); } vector<int>res; for (int m = 0; m < qlzifu.size(); m++) { for (int zyi = 0; zyi < zyzifu.size(); zyi++) { if (qlzifu[m] == zyzifu[zyi]) res.push_back(qlzfnum[m] - zyzfnum[zyi]); } res.push_back(qlzfnum[m]); } for (int no = 0; no < qlzifu.size(); no++) { if (res[no] <= 0) continue; string stmp(1, qlzifu[no]); res1.append(stmp); res1.append(":"); res1.append(to_string(res[no])); if (no < qlzifu.size() - 1) res1.append(","); } return res1;}int main() { string str; string res = getResult(str); cout << res << endl; return 0;}

（未做出，待补充）

（待补充）