vector

来源:互联网 发布:淘宝亲密付退款退到哪 编辑:程序博客网 时间:2024/04/30 01:46
#include<iostream>#include<string>//#include<cctype>#include<vector>using namespace std;int main(){/****************************************************************vector<string> text;string word;while (cin >> word){text.push_back(word);}for (auto c : text){cout << c << "  ";}cout << endl;*********************************************************************//************************************************************************unsigned int t;vector<unsigned int> score(11,0);while (cin >> t){if (t <= 100){++score[t / 10];}}for (auto c : score){cout << c << " ";}cout << endl;*************************************************************************//***************************************************************************string smallLetter;vector<string> bigLetter;while (cin >> smallLetter){bigLetter.push_back(smallLetter);}for (auto &c : bigLetter){if (!c.empty()){for (auto &s : c){s = toupper(s);}}}for (auto c : bigLetter){cout << c << " ";}cout << endl;*************************************************************************************************/    int a;vector<int> zhengshu;while (cin >> a){zhengshu.push_back(a);}unsigned int n = zhengshu.size();int i = 0;/**********************相邻两个数的和***********************for (auto &c : zhengshu){int temp = c;c += i;i = temp;cout << c << " ";}*************************第一个加最后一个********************/int j = 0;for (j = 0; j < (n / 2); ++j){cout << (zhengshu[j] + zhengshu[n - 1 - j]) << " ";}if (j * 2 < n){cout << zhengshu[j] << " ";}cout<<endl;/****************************************************************************string word;const string hexDigit="0123456789ABCDEF";string zong;int n;cout << "将字符串里的东西都换成x"<<endl;while (cin >> word){for (auto &c : word){c = 'x';}cout << word << endl;}cin.clear();system("PAUSE");cout << "去掉标点符号" << endl;while (cin >> word){for (auto&c : word){if (ispunct(c)){c = ' ';}}}cout << word << endl;cin.clear();system("PAUSE");cout << "十进制转16进制" << endl;while (cin >> n){if (n <= hexDigit.size()){zong = zong + hexDigit[n]+" ";}}cout << zong << endl;************************************************************************************************/system("PAUSE");return 0;}

0 0
原创粉丝点击