Thats it!!
![:D](./images/smilies/icon_biggrin.gif)
![:)](./images/smilies/icon_smile.gif)
![:D](./images/smilies/icon_biggrin.gif)
Moderator: Board moderators
asif_khan_ak_07 wrote:which data type should i use?
mf wrote:No, it ain't.
Code: Select all
Code: Select all
Code: Select all
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
vector<string> INPUTS;
vector<int> OUTPUTS;
void core()
{
int loop = INPUTS.size();
for(int i = 0; i < loop; i++)
{
int first = 0, second = 0;
string temp = INPUTS[i];
int count = temp.size();
first = atoi(&temp[0]);
for(int j = 0; j < count; j++)
{
if(isspace(temp[j]))
{
second = atoi(&temp[j + 1]);
break;
}
}
OUTPUTS.push_back(second - first);
}
}
int main(int argc, char *argv[])
{
ifstream the_file ("Input.txt");
if (!the_file.is_open())
{
cout<<"Could not open file\n";
//system("pause");
return 0;
}
else {
string x;
while ( !the_file.eof())
{
getline(the_file, x);
INPUTS.push_back(x);
}
the_file.close();
}
core();
ofstream file("output.txt");
if(!file.is_open())
{
cout<<"Fail to create dump file"<<endl;
//system("pause");
return 0;
}
else
{
//output to the output file
for(int a = 0; a <OUTPUTS.size(); a++ )
{
file<<OUTPUTS[a]<<endl;
}
}
file.close();
return 0;
}
Code: Select all
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]){
long a, b, c;
Scanner cin = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
while(cin.hasNextLong()){
a = cin.nextLong();
b = cin.nextLong();
c = a-b;
if(c<0) c *=-1;
System.out.println(c);
}
}
}
Code: Select all
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]){
long a, b, c;
Scanner cin = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
while(cin.hasNextLong()){
a = cin.nextLong();
b = cin.nextLong();
c = a-b;
if(c<0) c *=-1;
System.out.println(c);
}
}
}