(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;
}
 
 

 

 

转载于:https://www.cnblogs.com/xueda120/archive/2013/05/13/3076060.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值