Problem A

Hashmat the brave warrior

Input: standard input

Output: standard output

Hashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and the opponent's soldier number. From this difference he decides whether to fight or not. Hashmat's soldier number is never greater than his opponent.

Input

The input contains two integer numbers in every line. These two numbers in each line denotes the number of soldiers in Hashmat's army and his opponent's army or vice versa. The input numbers are not greater than 2^32. Input is terminated by End of File.

Output

For each line of input, print the difference of number of soldiers between Hashmat's army and his opponent's army. Each output should be in seperate line.

 

Sample Input:

10 12
10 14
100 200

 

Sample Output:

2
4
100

___________________________________________________________________________________ 
Shahriar Manzoor
16-12-2000

 #include <stdio.h>
#include <math.h>
int main()
{
long long a, b;
for (;scanf("%lld%lld", &a, &b) != EOF;)
printf("%lld\n", a < b ? b - a : a - b);
return ;
}

报告:本题原以为能很容易应付,结果做了两天都没做出来,最后还是参考网上的才完成,现在说下做题出现的问题:1,没看清题意,对or vice versa这个没理解,便理所当然的把第一个当作小于第二个的数。2,2的32次方应用long long来声明定义,却用了int,没理解给出数的范围的意思,其中也暴露了我没理解int型等数据类型的取值范围。3,EOF为CTRL+Z而不是CTRL+C,导致一直出错。

原因:1,英语不熟,且粗心大意,看了个大概便做题。2理所当然了,对数据类型的不熟悉。3对文件相关标志并不理解

解决:1,只能靠学英语解决。暂无解决 。2,int型当是2个字节时,一个字节为8位,则范围是2的-15次方到2的15次方,同理,long long型是8个字节时,则范围是2的-63次方到2的63次方,至于浮点数,暂先不涉猎。3,EOF即end of file,因为文本存储方式为ascii码,则范围为0~255,不存在-1,EOF表-1,返回EOF即表结束,在windows下为CTRL+Z,而linux下则是CTRL+D。

UVa OJ 10055的更多相关文章

  1. uva oj 567 - Risk(Floyd算法)

    /* 一张有20个顶点的图上. 依次输入每个点与哪些点直接相连. 并且多次询问两点间,最短需要经过几条路才能从一点到达另一点. bfs 水过 */ #include<iostream> # ...

  2. UVa OJ 194 - Triangle (三角形)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...

  3. UVa OJ 175 - Keywords (关键字)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Many researchers are faced with an ever increasing numbe ...

  4. UVa OJ 197 - Cube (立方体)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 There was once a 3 by 3 by 3 cube built of 27 smaller ...

  5. UVa OJ 180 - Eeny Meeny

    Time limit: 3.000 seconds限时3.000秒 Problem问题 In darkest <name of continent/island deleted to preve ...

  6. UVa OJ 140 - Bandwidth (带宽)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Given a graph (V,E) where V is a set of nodes and E is a ...

  7. 548 - Tree (UVa OJ)

    Tree You are to determine the value of the leaf node in a given binary tree that is the terminal nod ...

  8. UVa OJ 10300

    Problem A Ecological Premium Input: standard input Output: standard output Time Limit: 1 second Memo ...

  9. UVa OJ 10071

    Problem B Back to High School Physics Input: standard input Output: standard output A particle has i ...

随机推荐

  1. java线性表学习笔记(二)

    链表中的每一个元素都包含一个称为节点的结构,每向链表中增加一个元素,就会产生一个与之相关的节点,每个节点与它相邻的节点相连接(这是基础吧,不过在看c的时候没认真看,呼). 定义节点类如下(使用了泛型, ...

  2. 应用TcpListener实现的socket服务器端

    前言 项目中要实现一个简单的socket服务器端,采用了TcpListener这个类.除了基本的功能之外,有几处需要注意的点. 要能同时接收多个客户端的连接,当然,不需要几千个那么多. 要能探测到客户 ...

  3. rapsbian下配置ngrok

    访问https://ngrok.com,下载Linux/ARM版本的(因为PI为ARM的芯片,如果下载Linux版本的是无法正常使用的) 解压 $ unzip /path/to/ngrok.zip 注 ...

  4. XML的特殊字符处理

    XML中共有5个特殊的字符,分别是:&<>“’.如果配置文件中的注入值包括这些特殊字符,就需要进行特别处理.有两种解决方法:其一,采用本例中的<![CDATA[ ]]> ...

  5. POJ 2774 Long Long Message (后缀数组模板)

    借用罗大神的模板,开始搞后缀数组 #include <cstdio> #include <iostream> #include <cstring> #include ...

  6. Excel合并单元格数据

    1.=A1&B1 2.=CONCATENATE(A1,B1)

  7. 微信内置浏览器图片查看方式的原生实现(非jssdk)

    对于非公众平台网页,想调起图片预览组件,就跟公众号文章一样的图片阅读方式,实现起来是比较简单的,官方也提供了jssdk来做这个.详见 http://mp.weixin.qq.com/wiki/7/aa ...

  8. C# List 中 Find 方法

    实例化一个集合 List<User> userCollection = new List<User>(); userCollection.Add(new User(1, &qu ...

  9. android 绘图之Canvas,Paint类

    Canvas,Paint 1.在android 绘图但中经常要用到Canvas和Paint类,Canvas好比是一张画布,上面已经有你想绘制图画的轮廓了,而Paint就好比是画笔,就要给Canvas进 ...

  10. SQL SERVER 2005如何建立自动备份的维护计划

    SQL Server 2005中可以使用维护计划来为数据库自动备份,减少数据库管理员的工作负担.其使用方法如下: (1)启动[sql server Management Studio],在[对象资源管 ...