这是g++的有关问题吗?还是…
这是g++的问题吗?还是……
我在suse11.2下的g++4.4.1运行C++程序,出现以下错误,是什么原因??怎么解决????
test.cpp: In function ‘int main()’:
test.cpp:8: error: ‘stdin’ was not declared in this scope
test.cpp:8: error: ‘freopen’ was not declared in this scope
test.cpp:12: error: ‘memset’ was not declared in this scope
------解决方案--------------------
你缺了这几个函数的头文件...
------解决方案--------------------
楼主,你这是学C++呢,还是学C啊?
------解决方案--------------------
#include <stdio.h>
#include <mem.h>
------解决方案--------------------
C和C++搅合一起了
我在suse11.2下的g++4.4.1运行C++程序,出现以下错误,是什么原因??怎么解决????
test.cpp: In function ‘int main()’:
test.cpp:8: error: ‘stdin’ was not declared in this scope
test.cpp:8: error: ‘freopen’ was not declared in this scope
test.cpp:12: error: ‘memset’ was not declared in this scope
- C/C++ code
#include <iostream> #include <algorithm> #define max 100000 using namespace std; int num[max]; int main() { freopen("in.txt","r",stdin); int n; while(cin>>n) { memset(num,0,sizeof(num)); int m=(n+1)/2; int a,answer; for(int i=0;i<n;i++) { cin>>a;num[a]++; if(num[a]>=m) answer=a; } cout<<answer<<endl; } return 0; }
------解决方案--------------------
你缺了这几个函数的头文件...
------解决方案--------------------
楼主,你这是学C++呢,还是学C啊?
------解决方案--------------------
#include <stdio.h>
#include <mem.h>
------解决方案--------------------
C和C++搅合一起了