OJ_编排字符串

题目

C++实现

cpp 复制代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stack>
#include <string>
using namespace std;

int main() {
	stack<string> myStack;
	int m;
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		char strArr[200] = { 0 }; //注意这种初始化方式
		scanf("%s", strArr);
		string str = strArr; //转化为string类型
		myStack.push(str);

		stack<string> outputStack = myStack;
		for (int j = 1; j <= 4 ; j++)
		{
			if (outputStack.empty()) {
				break;
			}

			printf("%d=%s ", j, outputStack.top().c_str());
			outputStack.pop();
		}
		printf("\n");
	}
}
相关推荐
csdn_aspnet6 小时前
C++ 使总距离最短的最佳点位置(Optimum location of point to minimize total distance)
c++·算法
逐米时代8 小时前
「制造新解法」行业对标方法:借鉴而不照搬的最佳实践
人工智能·算法·制造
kyrie_sakura9 小时前
大模型学习32 --大模型微调3 -- 分布式训练算法
分布式·学习·算法
Rabitebla9 小时前
【Linux】 文件系统(五):挂载与软硬链接,多个文件系统怎样组成统一目录树
linux·运维·服务器·c++·笔记·学习·算法
m0_743106469 小时前
SAD-GS:从梯度邻域到频率驱动表达3D空间
人工智能·算法·计算机视觉·3d·几何学
csdn_aspnet10 小时前
Java 使总距离最短的最佳点位置(Optimum location of point to minimize total distance)
java·算法
专注仿真11 小时前
仿真智能体训练(评估指标篇):任务完成率算法详解与实战
人工智能·算法·机器学习·afsim智能体·仿真训练·afsim智能体训练·任务完成率算法
小手cool12 小时前
二分查找:在有序数组中查找最接近 target 的元素索引
java·数据结构·算法
zmzb010312 小时前
C++课后习题训练记录Day216
数据结构·c++·算法
INGNIGHT12 小时前
leetcode尊享100题
算法·哈希算法