标签:turn init main cin lin namespace 编译 test tput
#include <iostream> #include <cstdio> #include <string> #include <vector> using namespace std; int Vt[30],Vn[30]; vector<string> P; //char str[100]; int tl,nl; void init() { tl=nl=0; } void split(string str,string p) { int i; if(str=="") return; str+=p; int len = str.size(); int pos = str.find(p); cout<<str<<endl; while(pos!=len-1) { string x = str.substr(0,pos); P.push_back(x); str = str.substr(pos+1,len); pos = str.find(p); //cout<<x<<endl<<str<<endl; } } void test() { P.push_back("a"); } void input() { int i,len; string str; while(getline(cin,str) && str[0]!=‘q‘) { //len = strlen(str); //cout<<"a"<<len<<endl; len = str.size(); for(i =0;i<len;i++) { if(str[i]<=‘z‘ && str[i]>=‘a‘) Vt[str[i]-‘a‘]++; else if(str[i]!=‘S‘ && str[i]<=‘Z‘ && str[i]>=‘A‘) Vn[str[i]-‘A‘]++; } split(str,","); //test(); } } void output() { int i; cout<<"(Vt={"; for(i=0;i<26;i++) { if(Vt[i]) { cout<<(char)(‘a‘+i);i++;break; } } for(;i<26;i++) { if(Vt[i]) cout<<","<<(char)(‘a‘+i); } cout<<"},Vn={S"; for(i=0;i<26;i++) { if(Vn[i]) cout<<","<<(char)(‘A‘+i); } cout<<"},P={"; for(vector<string>::iterator it = P.begin(); it!=P.end();) { cout<<","<<*(it);it++; } cout<<"},S)"<<endl; } int main() { init(); input(); output(); return 0; }
标签:turn init main cin lin namespace 编译 test tput
原文地址:http://www.cnblogs.com/qlky/p/6555375.html