(TOJ2804)Even? Odd?

描述

Bessie's cruel second grade teacher has assigned a list of N (1 <= N <=100) positive integers I (1 <= I <=10^60) for which Bessie must determine their parity (explained in second grade as "Even... or odd?"). Bessie is overwhelmed by the size of the list and by the size of the numbers. After all, she only learned to count recently.

Write a program to read in the N integers and print 'even' on a single line for even numbers and likewise 'odd' for odd numbers.

输入

* Line 1: A single integer: N
* Lines 2..N+1: Line j+1 contains I_j, the j-th integer to determine even/odd

输出

* Lines 1..N: Line j contains the word 'even' or 'odd', depending on the parity of I_j

样例输入

2

1024

5931

样例输出

even

odd

#include<stdio.h>

#include<string.h>

#include<ctype.h>

#include<math.h>



int solve()

{

    char m,n;

    int N;

    scanf("%d",&N);

    getchar();

    while(N--)

    {    

      do

      {

          scanf("%c",&m);

          if(m!='\n')

            n=m;           //用n记录退出循环前的字符 

      }while(m!='\n');  //当m为换行符时候退出循环 

      if((n-'0')%2==0)   //判断末位数字的奇偶 

      {

          printf("even\n");

       }

      else

       {

          printf("odd\n");

       }

    }

  

}



int main()

{

  solve();

    return 0;

}
 
  

 

 

你可能感兴趣的:(OJ)