uva 10785 - The Mad Numerologist
这题就是计算元音和辅音的个数,放到两个容器里,再按字典序排序
一开始漏写了个辅音,错了一次
1 #include<iostream> 2 #include<vector> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 int n; 7 cin>>n; 8 vector<char> v_vowel; 9 vector<char> v_consonants; 10 char vowel[5]={'A','U','E','O','I'}; 11 char consonants[21]={'J','S', 12 'B','K','T', 13 'C','L', 14 'D','M','V', 15 'N','W', 16 'F','X', 17 'G','P','Y', 18 'H','Q','Z', 19 'R'}; 20 for(int i=0;i<n;i++){ 21 int len; 22 cin>>len; 23 cout<<"Case "<<i+1<<": "; 24 int vowellen=(len+1)/2; 25 int constlen=len/2; 26 for(int j=0;j<vowellen;j++){ 27 v_vowel.push_back(vowel[j/21]); 28 } 29 sort(v_vowel.begin(),v_vowel.end()); 30 for(int j=0;j<constlen;j++){ 31 v_consonants.push_back(consonants[j/5]); 32 } 33 sort(v_consonants.begin(),v_consonants.end()); 34 for(int j=0;j<len;j++){ 35 if(j%2==0) 36 cout<<v_vowel[j/2]; 37 if(j%2==1) 38 cout<<v_consonants[j/2]; 39 } 40 cout<<endl; 41 v_vowel.clear(); 42 v_consonants.clear(); 43 } 44 }
浙公网安备 33010602011771号