Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
71881 LJY 19灯的编号 C++ Compile Error 0 MS 0 KB 799 2024-04-27 18:00:55

Tests(0/0):


Code:

#include <iostream> #include <cstring> using namespace std; static int a[1000]; //全局变量放在数据区,可以开的更大 局部变量存放在栈区, // 动态变量存放在堆区,函数代码放在代码区 http://www.cnblogs.com/shineqiujuan/archive/2009/05/15/1457178.html int main() { memset(a,0,sizeof(a)); //在头文件cstring中定义,数组最好初始化 int m,n,i,j; int flag=1; //判断首个元素,不输出空格 cin>>m>>n; for(i=1 ; i<=n ; i++) //n人,依次进入 for(j=1;j<=m;j++) //m盏灯,依次进行操作 if(j%i == 0) a[j] = !a[j]; for(i=1; i<=m; i++) //输出,第一个元素前不留空格 if(a[i]) { if(flag) flag=0; else cout<<" "; cout << i; } cout<<endl; return 0; }


Run Info:

Main.cc:7:7: error: expected constructor, destructor, or type conversion before '(' token
 memset(a,0,sizeof(a));  //在头文件cstring中定义,数组最好初始化  
       ^
Main.cc:10:1: error: 'cin' does not name a type
 cin>>m>>n;  
 ^
Main.cc:11:1: error: expected unqualified-id before 'for'
 for(i=1 ; i<=n ; i++) //n人,依次进入  
 ^
Main.cc:11:11: error: 'i' does not name a type
 for(i=1 ; i<=n ; i++) //n人,依次进入  
           ^
Main.cc:11:18: error: 'i' does not name a type
 for(i=1 ; i<=n ; i++) //n人,依次进入  
                  ^
Main.cc:12:9: error: 'j' does not name a type
 for(j=1;j<=m;j++)  //m盏灯,依次进行操作  
         ^
Main.cc:12:14: error: 'j' does not name a type
 for(j=1;j<=m;j++)  //m盏灯,依次进行操作  
              ^
Main.cc:15:1: error: expected unqualified-id before 'for'
 for(i=1; i<=m; i++)  //输出,第一个元素前不留空格  
 ^
Main.cc:15:10: error: 'i' does not name a type
 for(i=1; i<=m; i++)  //输出,第一个元素前不留空格  
          ^
Main.cc:15:16: error: 'i' does not name a type
 for(i=1; i<=m; i++)  //输出,第一个元素前不留空格  
                ^
Main.cc:24:1: error: 'cout' does not name a type
 cout<