这个抱错是怎么回事?
程序代码:
#include<iostream> using namespace std; int main() { const int N=4; for(int i=1;i<=N;i++) { for(int j=1;j<=30;j++) cout<<' '; for(int j=1;j<=8-2*i;j++) cout<<' '; for(int j=1;j<=2*i-1;j++) cout<<'*'; cout<<endl; } for(int i=1;i<=N-1;i++) { for(int j=1;j<=30;j++) cout<<' '; for(int j=1;j<=7-2*i;j++) cout<<'*'; cout<<endl; } return 0; }
目的是输出一个图形
*
***
*****
*******
*****
***
*
我是初学的,这段是书上抄的,抱错如下
--------------------Configuration: fwef - Win32 Debug--------------------
Compiling...
fwef.cpp
E:\VC++\fwef.cpp(10) : error C2374: 'j' : redefinition; multiple initialization
E:\VC++\fwef.cpp(8) : see declaration of 'j'
E:\VC++\fwef.cpp(12) : error C2374: 'j' : redefinition; multiple initialization
E:\VC++\fwef.cpp(8) : see declaration of 'j'
E:\VC++\fwef.cpp(16) : error C2374: 'i' : redefinition; multiple initialization
E:\VC++\fwef.cpp(6) : see declaration of 'i'
E:\VC++\fwef.cpp(20) : error C2374: 'j' : redefinition; multiple initialization
E:\VC++\fwef.cpp(18) : see declaration of 'j'
执行 cl.exe 时出错.