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 ...
随机推荐
- java project打包生成jar包(通用)
1. 在工程目录下新建一个build.xml文件,如下图所示,注意必须是在工程目录下,而不是在工程目录的src目录里. 2.编写ant脚本,内容如下,jar文件名称(com.anllin.rup.bo ...
- 利用JS实现vue中的双向绑定
Vue 已经是主流框架了 它的好处也不用多说,都已经是大家公认的了 那我们就来理解一下Vue的单向数据绑定和双向数据绑定 然后再使用JS来实现Vue的双向数据绑定 单向数据绑定 指的是我们先把模板写好 ...
- [TypeScript] Dynamically Allocate Function Types with Conditional Types in TypeScript
Conditional types take generics one step further and allow you to test for a specific condition, bas ...
- css - font-size
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 微信小程序 - 滑动显示地点信息(map)
演示效果如下: 资源如下 marker,png index.wxml <view class="map-container"> <map id="map ...
- Instant Messaging for OpenERP v7
This module is based on the socket.io real time implementation. It inherit Of the modules web_longpo ...
- 我对GFWed的一些自己的见解
首先来听听维基百科对GFWed的说明 防火长城(英语:Great Firewall of China.经常使用简称:GFW,中文也称中国国家防火墙或防火长城[1],中国大陆民众俗称防火墙[2].功夫网 ...
- Spring 注解Autowired自动注入bean异常解决
错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xx' is defined ...
- 我也来谈谈使用Zen Coding快速开发html和css原理
zen coding 是一种仿css选择器的语法来快速开发html和css的开源项目.现已更名为Emmet.可以到github上下载拜读.在这个都想偷懒的世界里,此方法可以极大的缩短开发人员的开发时间 ...
- Java中super的几种使用方法并与this的差别
1. 子类的构造函数假设要引用super的话,必须把super放在函数的首位. class Base { Base() { System.out.println("Base" ...