为了
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
而编成下列代码,可是出错如下
--------------------Configuration: 3.左对齐 - Win32 Debug--------------------
Compiling...
3.左对齐.cpp
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : error C2059: syntax error : 'bad suffix on number'
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : error C2146: syntax error : missing ';' before identifier 'x'
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : error C2146: syntax error : missing ')' before identifier 'y'
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : warning C4552: '+' : operator has no effect; expected operator with side-effect
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : error C2059: syntax error : ';'
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(8) : error C2059: syntax error : ')'
D:\exercise\c primer plus\6\练习\3.左对齐.cpp(9) : error C2143: syntax error : missing ';' before '{'
Error executing cl.exe.
3.左对齐.obj - 6 error(s), 1 warning(s)
=======================================================================================================================
#include<stdio.h>
int main(void)
{
char y;
int x;
for(x=0;x<5;x++)
{
for(;y < 2x+1+'A';y++)
{
if(y>=x+1+'A')
printf("%c",'A'+x-y+2);
else
printf("%c",y);
}
printf("\n");
}
return 0;
}