读书人

初学者请大侠帮忙

发布时间: 2012-04-10 21:03:56 作者: rapoo

菜鸟请大侠帮忙
#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?中间要有*把
[解决办法]

C/C++ code
#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");    }} 

读书人网 >C语言

热点推荐