zoukankan      html  css  js  c++  java
  • (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;
    }
    
    
    
     
  • 相关阅读:
    2016年10月30日表单标签与样式表分类和选择器
    2016年10月29日常用标签与表格
    2016年10月28日网页属性和通用标签
    10月27日体会目标
    字符串学习笔记
    [51nod1789] 跑得比谁都快
    [洛谷9月月赛]签到题
    [LUOGU2730] 魔板
    [SCOI2009]迷路
    [51nod1074] 约瑟夫问题 V2
  • 原文地址:https://www.cnblogs.com/xueda120/p/3076060.html
Copyright © 2011-2022 走看看