菜鸟请大侠帮忙
#include<stdio.h>
int main()
{
int x,y,n;
scanf("%d",&n);
for(x=1;x<=n;x++)
{
for(y=1;y<=n-x;y++)
printf(" ");
for(y=1;y<=2x-1;y++)
printf("%d",x);
printf("\n");
}
}
----------------------
--------------------Configuration: feb - Win32 Debug--------------------
Compiling...
feb.cpp
F:\二级c\程序\feb26\feb.cpp(10) : error C2059: syntax error : 'bad suffix on number'
F:\二级c\程序\feb26\feb.cpp(10) : error C2146: syntax error : missing ';' before identifier 'x'
F:\二级c\程序\feb26\feb.cpp(10) : error C2146: syntax error : missing ')' before identifier 'y'
F:\二级c\程序\feb26\feb.cpp(10) : warning C4552: '-' : operator has no effect; expected operator with side-effect
F:\二级c\程序\feb26\feb.cpp(10) : error C2059: syntax error : ';'
F:\二级c\程序\feb26\feb.cpp(10) : error C2059: syntax error : ')'
F:\二级c\程序\feb26\feb.cpp(11) : error C2146: syntax error : missing ';' before identifier 'printf'
F:\二级c\程序\feb26\feb.cpp(14) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
feb.obj - 1 error(s), 0 warning(s)
本人刚开始学c语言,请问这个程序错在哪?
[解决办法]
2x?中间要有*把
[解决办法]
#include<stdio.h>int main(){ int x,y,n; scanf("%d",&n); for(x=1;x<=n;x++) { for(y=1;y<=n-x;y++) printf(" "); for(y=1;y<=2*x-1;y++) // printf("%d",x); printf("\n"); }}