首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

初学者请大侠帮忙

2012-04-10 
菜鸟请大侠帮忙#includestdio.hint main(){int x,y,nscanf(%d,&n)for(x1xnx++){for(y1yn-x

菜鸟请大侠帮忙
#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");    }} 

热点排行