CodeForces 616 A. Comparing Two Long Integers(水~)
2016-02-26 11:08
281 查看
Description
给出两个数字串,比较这两个数字串的大小
Input
两个数字串,串长均不会超过10^6
Output
比较两个数字的大小
Sample Input
00012345
12345
Sample Output
=
Solution
水题,先去掉前置0,之后比长度,长度相同则比较字典序
Code
给出两个数字串,比较这两个数字串的大小
Input
两个数字串,串长均不会超过10^6
Output
比较两个数字的大小
Sample Input
00012345
12345
Sample Output
=
Solution
水题,先去掉前置0,之后比长度,长度相同则比较字典序
Code
#include<cstdio> #include<iostream> #include<cstring> using namespace std; #define maxn 1111111 char a[maxn],b[maxn]; int main() { while(~scanf("%s%s",a,b)) { int la=strlen(a),lb=strlen(b); int i=0,j=0,flag; while(i<la&&a[i]=='0')i++; while(j<lb&&b[j]=='0')j++; if(la-i>lb-j)flag=1; else if(la-i<lb-j)flag=-1; else if(la-i==lb-j)flag=strcmp(a+i,b+j); if(flag==1)printf(">\n"); else if(flag==0)printf("=\n"); else printf("<\n"); } return 0; }
相关文章推荐
- MySQL学习网址
- C# 生成二维码并且在中间加Logo
- 常用网站
- 《小白的CFD之旅》招募写手
- Fence Device and Agent Information for Red Hat Enterprise Linux
- 怎样将几个pdf文件合并到一起
- iOS数据持久化-归档NSKeyedArchiver
- Aggressive cows(二分)
- 微信公众号-人脸识别(python)
- Oracle优化:千万级大表逻辑判断的累赘
- Android小方法
- Android WebView的使用
- CString 转化成 const char* 类型
- 7.UITextField
- iOS 设计模式 - 策略模式
- android编译做cmcc分支宏
- Android开发必备知识:为什么说Kotlin值得一试
- 自定义实现HashSet
- ART、JIT、AOT、Dalvik之间有什么关系?
- 跟踪“Visual Tracking with Fully Convolutional Networks”