当前位置: 首页 > news >正文

(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

相关文章:

  • Smack文档(翻译)转
  • UML 中关系详解以及在visio中的表示
  • linux下查找文件的常用命令
  • struts2-自定义拦截器
  • 敌兵布阵
  • Mac系统如何显示和隐藏文件
  • 无法读取配置节system.web.extensions,因为它缺少节声明
  • 【语言处理与Python】3.3使用Unicode进行文字处理
  • Android应用程序组件Content Provider应用实例
  • 整数数组关于大整数包的设计!
  • LINQ to Sql系列一 增,删,改
  • [NET].NET Framework 3.5 SP1 真正的离线安装(转)
  • 访问共享目录C#访问共享目录与Word.ApplicationClass发生冲突的解决办法
  • C语言的库函数
  • 鼠标函数VC++全局钩子实现鼠标坐标值实时捕获
  • Android Studio:GIT提交项目到远程仓库
  • github从入门到放弃(1)
  • Hibernate【inverse和cascade属性】知识要点
  • MySQL Access denied for user 'root'@'localhost' 解决方法
  • Promise初体验
  • Twitter赢在开放,三年创造奇迹
  • Vue.js-Day01
  • Webpack4 学习笔记 - 01:webpack的安装和简单配置
  • -- 查询加强-- 使用如何where子句进行筛选,% _ like的使用
  • - 概述 - 《设计模式(极简c++版)》
  • 汉诺塔算法
  • 机器学习中为什么要做归一化normalization
  • 区块链分支循环
  • 深度学习在携程攻略社区的应用
  • 什么软件可以提取视频中的音频制作成手机铃声
  • 移动端 h5开发相关内容总结(三)
  • 正则学习笔记
  • ​力扣解法汇总946-验证栈序列
  • ​如何在iOS手机上查看应用日志
  • $.type 怎么精确判断对象类型的 --(源码学习2)
  • (附源码)spring boot公选课在线选课系统 毕业设计 142011
  • (紀錄)[ASP.NET MVC][jQuery]-2 純手工打造屬於自己的 jQuery GridView (含完整程式碼下載)...
  • (十八)用JAVA编写MP3解码器——迷你播放器
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (一)Mocha源码阅读: 项目结构及命令行启动
  • (已解决)vue+element-ui实现个人中心,仿照原神
  • (原創) X61用戶,小心你的上蓋!! (NB) (ThinkPad) (X61)
  • (转)MVC3 类型“System.Web.Mvc.ModelClientValidationRule”同时存在
  • (状压dp)uva 10817 Headmaster's Headache
  • ./和../以及/和~之间的区别
  • .Net CoreRabbitMQ消息存储可靠机制
  • .net FrameWork简介,数组,枚举
  • .NET/ASP.NETMVC 深入剖析 Model元数据、HtmlHelper、自定义模板、模板的装饰者模式(二)...
  • .NET/C# 中设置当发生某个特定异常时进入断点(不借助 Visual Studio 的纯代码实现)
  • .Net语言中的StringBuilder:入门到精通
  • [120_移动开发Android]008_android开发之Pull操作xml文件
  • [Asp.net MVC]Asp.net MVC5系列——Razor语法
  • [C++] cout、wcout无法正常输出中文字符问题的深入调查(1):各种编译器测试
  • [DM复习]关联规则挖掘(下)
  • [DP 训练] Longest Run on a Snowboard, UVa 10285