UVa OJ 10055
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的更多相关文章
- uva oj 567 - Risk(Floyd算法)
/* 一张有20个顶点的图上. 依次输入每个点与哪些点直接相连. 并且多次询问两点间,最短需要经过几条路才能从一点到达另一点. bfs 水过 */ #include<iostream> # ...
- UVa OJ 194 - Triangle (三角形)
Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...
- UVa OJ 175 - Keywords (关键字)
Time limit: 3.000 seconds限时3.000秒 Problem问题 Many researchers are faced with an ever increasing numbe ...
- 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 ...
- UVa OJ 180 - Eeny Meeny
Time limit: 3.000 seconds限时3.000秒 Problem问题 In darkest <name of continent/island deleted to preve ...
- 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 ...
- 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 ...
- UVa OJ 10300
Problem A Ecological Premium Input: standard input Output: standard output Time Limit: 1 second Memo ...
- UVa OJ 10071
Problem B Back to High School Physics Input: standard input Output: standard output A particle has i ...
随机推荐
- 可变长参数列表误区与陷阱——va_arg不可接受的类型
可变长参数列表误区与陷阱--va_arg不可接受的类型 实现一个有可变长参数列表函数的时候,会使用到stdarg.h(这里不讨论varargs.h)中提供的宏. 例如,我们要实现一个简易的my_pri ...
- -g vs -rdynamic
[-g vs -rdynamic] -g选项与-rdynamic选项的差别:1,-g选项新添加的是调试信息(一系列.debug_xxx段),被相关调试工具,比如gdb使用,可以被strip掉. 2,- ...
- 【下有对策】verycd没有的资源有很多方法下载
由于国内专门从事假冒电驴官方欺骗中国人的verycd公司出品的冒牌官方电驴"阉割驴"目前已经阉割掉了搜索功能,请电驴爱好者们尽快更换正宗版电驴软件: 电骡--emule官方网站:h ...
- c# 解决IIS写Excel的权限问题
c# 解决IIS写Excel的权限问题 from: http://www.jb51.net/article/31473.htm 发布:mdxy-dxy 字体:[增加 减小] 类型:转载 使用以上方法必 ...
- CCF 201403-1 相反数 (水题)
问题描述 有 N 个非零且各不相同的整数.请你编一个程序求出它们中有多少对相反数(a 和 -a 为一对相反数). 输入格式 第一行包含一个正整数 N.(1 ≤ N ≤ 500). 第二行为 N 个用单 ...
- C# JackLib系列之Form窗体的ShowWithoutActivation属性及其作用
代码改变世界! 如果要显示顶级窗口,但又不希望由于将输入焦点从当前窗口移开而中断用户的工作,请使用此属性.它可以是一个信息性弹出窗口或浮动窗口,如“画图”应用程序中的“工具”调色板. 由于此属性为只读 ...
- jQuery在updatepanel中使用造成内存泄露
wijmo用户反馈了一个RadialGauge控件内存泄露的bug,采用chrome监控内存使用情况,发现明显的内存泄露,在前面的文章中我就发现了jQuery内存泄露的问题,这次再次发现此问题,自然就 ...
- 图说Java —— 理解Java机制最受欢迎的8幅图
原文链接: Top 8 Diagrams for Understanding Java 翻译人员: 铁锚 翻译时间: 2013年10月29日 世间总是一图胜过千万言! 下面的8幅图来自于 Progr ...
- 将php配置为服务
将以下代码保存为php-fpm,修改路径为自己的路径(有php.ini的) #!/bin/bash # # Startup script for the PHP-FPM server. # # chk ...
- OC键值观察KVO
什么是KVO? 什么是KVO?KVO是Key-Value Observing的简称,翻译成中文就是键值观察.这是iOS支持的一种机制,用来做什么呢?我们在开发应用时经常需要进行通信,比如一个model ...