#栈简单应用#倒序字符串#acwing

https://www.acwing.com/problem/content/description/3578/

#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
using namespace std;

int main(){
    int m;
    stack<string> Mystack;
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        char arr[200]={0};
        scanf("%s",arr);
        string str=arr;
        Mystack.push(str);

        stack<string> tmp = Mystack;
        for(int j=1;j<=4;j++){
            if(tmp.empty()) break;

            printf("%d=%s ",j,tmp.top().c_str());
            tmp.pop();
        }
        printf("\n");
    }
    return 0;
}

全部评论

相关推荐

练习生懒羊羊:开飞机把这个公司创飞吧
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务