Hello.
I have created a simple program which generates 3 random numbers, puts them in a text file, reads them, and then does 3 small calculations, results are put in another text file.
Program is working correctly on my PC, however there is a catch. I need to submit it on the server of my University. Source file will then be compiled on the server, and answers of my program will be compared to the correct answers.
Problem is, I don't know what is the C++ version on the University server. All I know, it is running on Linux/GNU. I have tried submitting the file, and I keep receiving compilation errors.
#include <iostream>
#include <fstream>
#include <stdlib>
int main(){
randomize();
ofstream fails3;
fails3.open("trissk.dat",ios::out);
int d=random(100)+1;
int e=random(100)+1;
int f=random(100)+1;
fails3<<d<<" ";
fails3<<e<<" ";
fails3<<f;
fails3.close();
int a,b,c;
ifstream fails1;
ofstream fails2;
fails1.open("trissk.dat", ios::in);
fails2.open("trissk.rez", ios::out);
while(!fails1.eof())
{
// mainigo seciba ir svariga...
fails1>>a;
fails1>>b;
fails1>>c;
if(!fails1.eof())
{
cout<<a<<" "<<b<<" "<<c;
}
}
if((a+b)>0||(b+c)>0||(c+a)>0){
fails2<<"VAR\n";}else{fails2<<"NEVAR\n";}
if((a+b)==0||(b+c)==0||(c+a)==0){
fails2<<"VAR\n";}else{fails2<<"NEVAR\n";}
if((a+b)<0||(b+c)<0||(c+a)<0){
fails2<<"VAR";}else{fails2<<"NEVAR";}
fails2.close();
fails1.close();
return 0;
}
I am sure the problem has something to do with the bolded line and headers.
Compilation errors I receive after uploading the source file:
[B][I]../programs/34299.cpp:3:18: error: stdlib: No such file or directory[/I][/B]
../programs/34299.cpp: In function 'int main()':
../programs/34299.cpp:6: error: 'randomize' was not declared in this scope
../programs/34299.cpp:7: error: 'ofstream' was not declared in this scope
../programs/34299.cpp:7: error: expected `;' before 'fails3'
../programs/34299.cpp:8: error: 'fails3' was not declared in this scope
../programs/34299.cpp:8: error: 'ios' has not been declared
/usr/include/stdlib.h:327: error: too many arguments to function 'long int random()'
../programs/34299.cpp:9: error: at this point in file
/usr/include/stdlib.h:327: error: too many arguments to function 'long int random()'
../programs/34299.cpp:10: error: at this point in file
/usr/include/stdlib.h:327: error: too many arguments to function 'long int random()'
../programs/34299.cpp:11: error: at this point in file
../programs/34299.cpp:25: error: 'ifstream' was not declared in this scope
../programs/34299.cpp:25: error: expected `;' before 'fails1'
../programs/34299.cpp:26: error: expected `;' before 'fails2'
../programs/34299.cpp:27: error: 'fails1' was not declared in this scope
../programs/34299.cpp:27: error: 'ios' has not been declared
../programs/34299.cpp:28: error: 'fails2' was not declared in this scope
../programs/34299.cpp:28: error: 'ios' has not been declared
../programs/34299.cpp:37: error: 'cout' was not declared in this scope