始终显示格式错误,求大佬帮忙看看,谢谢~
#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
全部评论
已解决,谢谢~
相关推荐
01-30 22:03
门头沟学院 Java
用微笑面对困难:我滴妈,【俩月】【实习】【主管】仨debuff吃满了,独立设计开发的项目写了绝大占比的运营板块,你独立开发,那维护、问题复盘、日志更新、bug、策划书全是自己整的? 点赞 评论 收藏
分享
查看16道真题和解析