int主要错误 [英] int main error
问题描述
我是C +的新手
我的作业如下:
编写一个包含for循环的C ++程序来打印消息
DooBeeDooBeeDooBeeDooBeeDooBeeDooBee请
我的代码到目前为止是
#include< iostream>
using namespace std;
int main()
{
int Doo;
int Bee ;
for(int Doo = 0; Doo< 6; Doo ++)
for(int Bee = 0; Bee< 6; Bee ++)
std :: cout<< " Bee"<< std ::;
std :: cout<< Doo<< std ::;
}
我的错误消息如下
DooBee.cpp:在函数中,aint main()a:
DooBee.cpp:11:错误:预期的非限定标识在一个之前;一个标记
DooBee.cpp:12:错误:在a之前预期的unqualified-id;令牌
展开 | 选择 | Wrap | 行号
我并不是说我需要在一行上使用它。
你建议修复main()
从中取出 int 这个循环。
这样做是创建另一个名为Bee的int循环本地。此局部变量隐藏了您在循环外定义的变量。对两个变量执行此操作。
I am very new with C++
I have an assignment that follows
Write a C++ program containing a for loop to print the message
DooBeeDooBeeDooBeeDooBeeDooBeeDooBee Do
My code so far is
#include <iostream>
using namespace std;
int main ()
{
int Doo;
int Bee;
for (int Doo = 0; Doo < 6; Doo++)
for (int Bee = 0; Bee < 6; Bee++)
std::cout << "Bee"<<std::;
std::cout << "Doo"<<std::;
}
My error messages follows
DooBee.cpp: In function aint main()a:
DooBee.cpp:11: error: expected unqualified-id before a;a token
DooBee.cpp:12: error: expected unqualified-id before a;a token解决方案Expand|Select|Wrap|Line Numbers
I didn''t mean endl I need it all on one line.
What do you suggest to fix the main ()
Take the word int out of your for loops.
What this is doing is creating another int named Bee that is local to the loop. This local variable is hiding the one you defined outside the loop. Do this for both variables.
这篇关于int主要错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文