问题标题: 酷町堂:1141

0
0
已解决
李素妍
李素妍
新手天翼
新手天翼

思路

李素妍在2020-08-08 17:25:03追加了内容

看代码

#include <iostream>
#include <string>
using namespace std;
int  front;
string a[110];
int main(){
    string s,b;
    int cnt=0;
    getline(cin,s);
    s=" "+s+" ";
    for(int i=1;i<s.size();i++){
          if(s[i-1]==' ' && s[i]!=' ') front=i;
          if(s[i+1]==' ' && s[i]!=' '){
           b=s.substr(front,i-front+1);
           for(int j=0;j<b.size();j++)
                cout<<b[j];
            }
           if(s[i]==' ') cout<<s[i];
    }
    return 0;
}

李素妍在2020-08-08 17:27:53追加了内容

#include <iostream>
#include <string>
using namespace std;
int main(){
    string a,b;
    int i=0;
    while(cin>>a){
        i++;
    }
    for(int j=i-1;j>0;j--){
        cout<<a[j];
    }
    return 0;
}

李素妍在2020-08-08 17:30:40追加了内容

#include <iostream>
#include <string>
using namespace std;
string a[110];
int main(){
    int i=0;
    while(cin>>a[++i]){
        i++;
    }
    for(int j=i-1;j>0;j--){
        cout<<a[j];
    }
    return 0;
}

再看

李素妍在2020-08-08 17:35:42追加了内容

@宣海宁  我要杀了你

#include <iostream>
#include <string>
using namespace std;
string a[110];
int main(){
    int i=0;
    while(cin>>a[++i]){
    }
    for(int j=i;j>1;j--){
        cout<<a[j];
    }
    return 0;
}

李素妍在2020-08-08 17:40:32追加了内容

#include <iostream>
#include <string>
using namespace std;
string a[110];
int main(){
    int i=0;
    while(cin>>a[++i])
    for(int j=i;j>=1;j--){
        cout<<a[j];
    }
    return 0;
}


0
已采纳
宣海宁
宣海宁
中级光能
中级光能

用while(cin>>a)

宣海宁在2020-08-08 17:42:58追加了内容
while(cin>>a[++i]);
    for(int j=i-1;j>=1;j--){
        cout<<a[j]<<' ';
    }

 

0
陈喆鹏
陈喆鹏
资深光能
资深光能

while(cin>>s[++l]);

然后反着输出

0
杜智宸
杜智宸
中级光能
中级光能

打开百度搜索题目内容,你会感谢我的

我要回答