始终显示格式错误,求大佬帮忙看看,谢谢~
#include<string>
(5850)#include<iostream>
using namespace std;
int main()
{
string s;
while(cin>>s)
{
int left = 0, right = s.length()-1;
int n1,n2,n3;
n1 = n3 = (s.length()+2)/3;
n2 = s.length()+2 - (s.length()+2)*2/3;
for(int i = 1; i < n1; i++)
{
cout<<s[left++];
for(int j = 1; j <= n2-2; j++)
cout<<' ';
cout<<s[right--]<<endl;
}
while(left<=right)
cout<<s[left++];
cout<<endl;
}
}
#include<string>
(5850)#include<iostream>
using namespace std;
int main()
{
string s;
while(cin>>s)
{
int left = 0, right = s.length()-1;
int n1,n2,n3;
n1 = n3 = (s.length()+2)/3;
n2 = s.length()+2 - (s.length()+2)*2/3;
for(int i = 1; i < n1; i++)
{
cout<<s[left++];
for(int j = 1; j <= n2-2; j++)
cout<<' ';
cout<<s[right--]<<endl;
}
while(left<=right)
cout<<s[left++];
cout<<endl;
}
}
「求助大佬帮看看这道算法题吧!」Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. Fo...
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2FquestionTerminal%2Fc6e414fddd7c401887c350c9cc41f01b
全部评论
已解决,谢谢~
相关推荐
点赞 评论 收藏
分享
2025-12-28 16:32
重庆邮电大学 Java
程序员花海:1.技能放最后,来面试默认你都会,技能没啥用
2.实习写的看起来没啥含金量,多读读部门文档,包装下 接LLM这个没含金量 也不要用重构这种 不会给实习生做的
3.抽奖这个还是Demo项目,实际在公司里面要考虑策略,满减,触发点,触发规则 库存 之类的,不是这个项目这么简单
4.教育背景提前,格式为 教育背景 实习 项目 技能 自我评价 点赞 评论 收藏
分享

