测试点4、5:确保最后一位没有非大写字母输出的时候,最后一个单词输出完整
测试点2、3:确保最后多位都是非大写字母输出的时候,不多输出一个空格
未测试的内容:未出现大写字母前是否出现非大写字母
1 #include <iostream> 2 using namespace std; 3 4 int main(){ 5 char list[182][5]; 6 bool flag = false; 7 for(int i = 0; i < 182; i++) 8 for(int j = 0; j < 5; j++) 9 cin >> list[i][j]; 10 string str, word = ""; 11 getchar(); 12 getline(cin, str); 13 for(int i = 0; i < str.length(); i++){ 14 if(str.at(i) >= 'A' && str.at(i) <= 'Z') word += str[i]; 15 if((str.at(i) < 'A' || str.at(i) > 'Z') || i == str.length() - 1){ 16 if(word.length() == 0) continue; 17 if(flag) cout << endl; 18 flag = true; 19 int j = 0; 20 while(j < 7){ 21 for(int k = 0; k < word.size(); k++){ 22 int chn = (word.at(k) - 'A') * 7; 23 if(k != 0) cout << " "; 24 for(int p = 0; p < 5; p++) cout << list[chn+j][p]; 25 } 26 j++; 27 cout << endl; 28 } 29 word = ""; 30 } 31 } 32 return 0; 33 }
浙公网安备 33010602011771号