Hi there. I'm trying to solve this problem :
http://acm.uva.es/p/v111/11172.html
So i wrote this:
Code:
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
int pairs;
int i, first, second;
char pFirst[80], pSecond[80];
char buffer[80];
char szFile[80];
cout << "Give the name of the file : " << endl;
cin >> szFile;
ifstream my_file(szFile);
if(!my_file) {cerr<<"No such file"<<endl;getchar();exit(1);}
my_file.getline(buffer,80);
pairs=atoi(buffer);
for(i=0;i<pairs;i++)
{
my_file.getline(pFirst,80,' ');
my_file.getline(pSecond,80);
first = atoi(pFirst);
second = atoi(pSecond);
if(first>second) cout << '>' << endl;
else if(first<second) cout << '<' << endl;
else cout << '=' << endl;
}
cin.get();
return 0;
}
My code works fine (shows the correct results) both in VS 2005 and dev-C++. But, when I submited it to the uva, it was not accepted( had runtime or compilation error)
The weird thing about this problem is that although it needs to load a file as input,
(in uva) I am asked to upload only my code....
It's the first time I upload a code there and I'm a bit fuzzed. Can you please help me?