怪,大家看这道题错哪里了?
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;
}