1249 Problem Q
问题 Q: 比大小
时间限制: 1 Sec 内存限制: 128 MB 提交: 159 解决: 66 [提交][状态][讨论版]
题目描述
给你两个很大的数,你能不能判断出他们两个数的大小呢? 比如123456789123456789要大于-123456
输入
每组测试数据占一行,输入两个不超过1000位的10进制整数a,b 数据保证输入的a,b没有前缀的0。 如果输入0 0表示输入结束。测试数据组数不超过10组
输出
如果a>b则输出“a>b”,如果a<b则输出“a<b”,如果相等则输出“a==b”。
样例输入
111111111111111111111111111 88888888888888888888
-1111111111111111111111111 22222222
0 0
样例输出
a>b
a<b
#include <iostream>
#include <string.h> using namespace std; char a[],b[];
int cut;
int na,nb;
int main()
{
while(cin>>a>>b)
{
if(a[]==''&&b[]=='')
break;
if(a[]!='-'&&b[]=='-')
{
cout<<"a>b"<<endl;
continue;
}
if(a[]=='-'&&b[]!='-')
{
cout<<"a<b"<<endl;
continue;
}
cut=;
if(a[]=='-'&&b[]=='-') cut=;
na=strlen(a+cut);
nb=strlen(b+cut);
if(na>nb&&cut==)
{
cout<<"a>b"<<endl;
continue;
}
if(na>nb&&cut==)
{
cout<<"a<b"<<endl;
continue;
}
if(na<nb&&cut==)
{
cout<<"a<b"<<endl;
continue;
}
if(na<nb&&cut==)
{
cout<<"a>b"<<endl;
continue;
}
for(int i=cut;i<na+cut;i++)
{
if(a[i]>b[i])
{
if(cut==)
{
cout<<"a>b"<<endl;
cut=-;
break;
}
else
{
cout<<"a<b"<<endl;
cut=-;
break;
}
}
if(a[i]<b[i])
{
if(cut==)
{
cout<<"a<b"<<endl;
cut=-;
break;
}
else
{
cout<<"a>b"<<endl;
cut=-;
break;
}
}
}
if(cut!=-)
cout<<"a==b"<<endl;
}
return ;
}
1249 Problem Q的更多相关文章
- Problem Q: C语言习题 计算该日在本年中是第几天
Problem Q: C语言习题 计算该日在本年中是第几天 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 4572 Solved: 2474[Subm ...
- Problem Q
Problem Description A factory produces products packed in square packets of the same height h and of ...
- Problem Q: 多项式求和x+(x^2)/2!+(x^3)/3!+...
#include<stdio.h> #include<math.h> int main() { float x,i; scanf("%f",&x); ...
- Problem Q: 零起点学算法12——求2个日期之间的天数
#include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...
- 证明与计算(1): Decision Problem, Formal Language L, P and NP
0x01 从判定问题到形式语言 这篇讲知识证明的wiki([1]): https://en.wikipedia.org/wiki/Proof_of_knowledge 里面有一句话: Let x be ...
- Q - Phalanx
题目链接:https://vjudge.net/contest/68966#problem/Q 分析:这里的对称并不是指的是关于原矩阵(也就是最大的那一个)主对角线对称,而是对于每一个小的矩阵来说,当 ...
- Codeforces--Books Exchange (hard version)
题目链接http://codeforces.com/contest/1249/problem/B2 .并查集思想,将数分成多个集合,每个集合的大小就是一轮的所需天数. Map[i]存储数据. flag ...
- Codeforces--C2. Good Numbers (hard version)
题目链接http://codeforces.com/contest/1249/problem/C2.这是道进制转换题,我们的目的是找到最小的一个每个位都是1的三进制数来表示一个十进制数n.做法是,先将 ...
- 二分图水一波~~~~d带你飞
Current Time: 2016-03-11 17:45:36 Contest Type: Public Start Time: 2016-03-04 13:00:00 Contest Statu ...
随机推荐
- (原创)sklearn中 F1-micro 与 F1-macro区别和计算原理
最近在使用sklearn做分类时候,用到metrics中的评价函数,其中有一个非常重要的评价函数是F1值,(关于这个值的原理自行google或者百度) 在sklearn中的计算F1的函数为 f1_sc ...
- 面试题:判断两个字符串是否互为回环变位(Circular Rotaion)
题干: 如果字符串 s 中的字符循环移动任意位置之后能够得到另一个字符串 t,那么 s 就被称为 t 的回环变位(circular rotation). 例如,ACTGACG 就是 TGACG ...
- Kafka 集群搭建 (自用)
Zookeeper集群搭建 1.软件环境 (3台服务器-测试环境) 192.168.56.9 192.168.56.6 192.168.56.7 1.Linux服务器一台.三台.五台.(2*n+1), ...
- infer 编译代码审查命令记录
infer -- xcodebuild -target <target name> -configuration <build configuration> -sdk ipho ...
- jquery ajax/post 请求 案例
@RequestMapping("/hello") @ResponseBody public Hello getJson(HttpServletRequest requ ...
- MVC你是怎样理解的?
近期的学术交流会议都在研究MVC,秉着好好学习,天天向上的心理,时不时的就去蹭会.说实话,原来也有看过MVC的一些相关资料,可是仅仅是浅尝辄止.并且,由于先学了三层,所以再看MVC的时候,潜意识里的就 ...
- 使用apache POI解析Excel文件
1. Apache POI简介 Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程式对Microsoft Office格式档案读和写的功能. 2. POI结构 ...
- MongoDB笔记(二):MongoDB下Shell的基本操作
一.mongoDB与关系型数据库对比 对比项 mongoDB 关系型数据库(oracle.mysql) 表 集合List 二维表table 表的一行数 ...
- Xcode, does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) 解决办法
在Build Settings中找到Enable Bitcode项,设置为如下: 参考:http://blog.csdn.net/soindy/article/details/48519363
- VA使用技巧
Reserved String Meaning Date $DATE$ Year/month/day formatted as %04d/%02d/%02d $DAY$ Day of month ...