Input output sample - 08

Input Specification:
The first line of Input file contains an integer n denotes the number of test case.Each test case contains a line. There are one or more integers in this line.

Output Specification:
For each test case output the maximum number.(See the sample I/O)

Sample Input:
2
10 5 7 9 10 3
4 7 8

Sample Output:
10
8


C Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define size 1000

int main(){
   char inputStr[size],*tempStr;
   int minNum,num,cas;
   scanf("%d",&cas);
   getchar();  // To ignore new line
   while(cas--){
       gets(inputStr);
       tempStr = strtok(inputStr," ");
       minNum = atoi(tempStr);
       while(tempStr!=NULL){
           num = atoi(tempStr);
           if(num<minNum)
               minNum=num;
           tempStr=strtok(NULL," ");
       }
       printf("%d\n",minNum);
   }
   return 0;
}


C++ Code:
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
   string inputStr,tempStr;
   int maxNum,num,cas;
   cin>>cas;
   getchar();  // To ignore new line
   while(cas--){
       getline(cin,inputStr);
       istringstream token(inputStr);
       token>>tempStr;
       maxNum = atoi(tempStr.c_str());
       while(token){
           token >> tempStr;
           num = atoi(tempStr.c_str());
           if(num>maxNum)
               maxNum=num;
       }
       cout<<maxNum<<endl;
   }
   return 0;
}