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;
    }
    
    
    
     
  • 相关阅读:
    java进程自动杀死
    线程池的取值(一)与拒绝策略
    zju 1383 Binary Numbers
    可以连续几行数,,,分别相加求和
    几个数字的和
    zju 2812 Quicksum---------hdu 2734
    rwkj 1332 C语言实验四(函数):题目1、数字根
    zju 1295 Reverse Text
    zju 1241 Geometry Made Simple
    hdu 1379 DNA Sorting
  • 原文地址:https://www.cnblogs.com/xueda120/p/3076060.html
Copyright © 2011-2022 走看看