Monday, February 24, 2014

codeforces easy round problem B1 - the smallest number solution & stdin from .txt text files & stdout to .txt text files

codeforces easy round problem B1 - the smallest number :
http://codeforces.com/gym/200470/problem/B1

B1. The smallest number
time limit per test
1 second
memory limit per test
64 megabytes
input
input.txt
output
output.txt
At school, Jonny learns to compare numbers. But he wants to play again, and again you have to do it for him. You need to find the smaller of the two numbers. Note that for input-output files are used!
Input
The only line of input file contains two integers a and b ( - 106 <  = a, b <  = 106) It is guaranteed that a is not equal to b
Output
In a single line of output file output-singular answer to the problem
Sample test(s)
input
2 -3
output
-3
input
1 2
output
1
codeforces easy round problem B1 - the smallest number solution : http://codeforces.com/gym/200470/submission/6100763
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    //#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    //#endif
    int a, b;
    scanf("%d%d", &a, &b);
    if(a<b) printf("%d", a);
    else printf("%d", b);
    return 0;
}

note: for input .txt - text files and output .txt - text files from c++(cpp) language just use :
 freopen("input.txt", "rt", stdin);
 freopen("output.txt", "wt", stdout);

No comments:

Post a Comment