怪,大家看这道题错哪里了?

ly00 2003-05-07 08:16:09
Zorro is ready to modernize -- he is tired of hand drawing his giant "Z", and would like to add an educational element. So he wants you to write a program to draw a Z using the lower-case letters of the alphabet in order. If you run out of letters, just continue by following z with a.

Input:

A positive integer denoting the number of characters across the top of the Z. An input of 0 will indicate that Zorro is done.

Output:

The Z, drawn in lowercase alphabetic characters. Each Z should be separated from the previous Z by at least one blank line.

Example:
Input:

3
30
0
Output:

abc
d
efg

abcdefghijklmnopqrstuvwxyzabcd
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
ghijklmnopqrstuvwxyzabcdefghij




#include<string>
#include<iomanip>
#include<iostream>
#include<list>
using namespace std;

int main(){
int s;
int j=0;
string a;
a="abcdefghijklmnopqrstuvwxyz";
list<int>vs;
while(cin>>s&&s!=0) vs.push_back(s);
int sz=vs.size();
for(int i=0;i<sz;i++)
{
s=vs.front();
vs.pop_front();
for(int k=0;k<s;k++){
j=k%26;
cout<<a[j];}
cout<<endl;
int tmp=25-j;

int i=0;

for(;i<s-2;i++){
j=j<=25?j:0;
cout<<setw(s-i-1)<<a[j]<<"\n";
j++;}

for(i=0;i<s;i++)
{
j=j<=25?j:0;
cout<<a[j];
j++;
}
cout<<"\n\n";
}
return 0;
}
...全文
74 18 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
19830711 2003-05-13
  • 打赏
  • 举报
回复
我也不知道呀
zolas 2003-05-12
  • 打赏
  • 举报
回复
呵呵,那我是你的前辈。 :)
今年亚洲预赛在哪儿举行?
zolas 2003-05-12
  • 打赏
  • 举报
回复
我只有MSN:eg99@msn.com
或者e-mail:zolas@163.com
witcheese 2003-05-12
  • 打赏
  • 举报
回复
..
ly00 2003-05-12
  • 打赏
  • 举报
回复
:)
希望以后大家多交流
oicq:83011904
e-mail:weiminzhilong@sohu.com
ly00 2003-05-11
  • 打赏
  • 举报
回复
^_^c没有学过
楼上的兄弟好眼力!
zolas 2003-05-11
  • 打赏
  • 举报
回复
还不如用printf来得方便……
BTW,老兄你这题风格很象ACM大学生计算机程序设计竞赛的题目,呵呵。
ly00 2003-05-11
  • 打赏
  • 举报
回复
用setw(s-i-1)再linux下为什么不能正确设置域宽呢,现在作了如下更改,可是提交到编译器还是不正确,请大家多帮忙,谢谢!
#include<string>
#include<iomanip>
#include<iostream>
#include<list>

using namespace std;

void outputblank(int num)
{for(int i=1;i<num;i++)
cout<<" ";}
int main(){
int s;
int j=0;
string a;
a="abcdefghijklmnopqrstuvwxyz";
list<int>vs;
while(cin>>s&&s!=0) vs.push_back(s);
int sz=vs.size();
for(int i=0,lf=1;i<sz;i++,lf++)
{
s=vs.front();
vs.pop_front();
for(int k=0;k<s;k++){
j=k%26;
cout<<a[j];}
j++;
cout<<endl;//first part;
//num of alphas first line has show;
//next position;

//second part:first alpha's offset is s-1;the last is 1;
//get offset;

for(int i=0;i<s-2;i++){
j=j<=25?j:0;
outputblank(s-i-1);
cout<<a[j]<<"\n";
j++;}

for(int i=0;i<s;i++)
{
j=j<=25?j:0;
cout<<a[j];
j++;
}
if(lf<sz) cout<<"\n\n";
}
return 0;
}
xhuagen 2003-05-11
  • 打赏
  • 举报
回复
right
doer_ljy 2003-05-10
  • 打赏
  • 举报
回复
我也用的g++
可以运行,只是中间你一段不是斜线是直线!
程序本身没问题吧!
也不会是编译器的问题!
ly00 2003-05-09
  • 打赏
  • 举报
回复
难道这样简单的问题,csdn都没人可以解决,或者不屑一看???
dragonlw 2003-05-09
  • 打赏
  • 举报
回复
是啊,很好用啊。不过我用的是vc6了!
ly00 2003-05-09
  • 打赏
  • 举报
回复
再我的dev-c++也无问题啊,大家帮想想还有什么没有考虑的情况没有,谢谢。
ly00 2003-05-09
  • 打赏
  • 举报
回复
是不是redhat linux的编译器和vc有不同标准?
总是这种情况,都快没信心了...
see22 2003-05-09
  • 打赏
  • 举报
回复
我在linux下试了,没问题,我用的是g++
ly00 2003-05-07
  • 打赏
  • 举报
回复
对了,服务器是redhat linux,我用的是dev-c++。
ly00 2003-05-07
  • 打赏
  • 举报
回复
总提示:wrong answer!
cylon 2003-05-07
  • 打赏
  • 举报
回复
VC测试通过,很好啊

24,860

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧