问题 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的更多相关文章

  1. Problem Q: C语言习题 计算该日在本年中是第几天

    Problem Q: C语言习题 计算该日在本年中是第几天 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 4572  Solved: 2474[Subm ...

  2. Problem Q

    Problem Description A factory produces products packed in square packets of the same height h and of ...

  3. Problem Q: 多项式求和x+(x^2)/2!+(x^3)/3!+...

    #include<stdio.h> #include<math.h> int main() { float x,i; scanf("%f",&x); ...

  4. Problem Q: 零起点学算法12——求2个日期之间的天数

    #include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...

  5. 证明与计算(1): Decision Problem, Formal Language L, P and NP

    0x01 从判定问题到形式语言 这篇讲知识证明的wiki([1]): https://en.wikipedia.org/wiki/Proof_of_knowledge 里面有一句话: Let x be ...

  6. Q - Phalanx

    题目链接:https://vjudge.net/contest/68966#problem/Q 分析:这里的对称并不是指的是关于原矩阵(也就是最大的那一个)主对角线对称,而是对于每一个小的矩阵来说,当 ...

  7. Codeforces--Books Exchange (hard version)

    题目链接http://codeforces.com/contest/1249/problem/B2 .并查集思想,将数分成多个集合,每个集合的大小就是一轮的所需天数. Map[i]存储数据. flag ...

  8. Codeforces--C2. Good Numbers (hard version)

    题目链接http://codeforces.com/contest/1249/problem/C2.这是道进制转换题,我们的目的是找到最小的一个每个位都是1的三进制数来表示一个十进制数n.做法是,先将 ...

  9. 二分图水一波~~~~d带你飞

    Current Time: 2016-03-11 17:45:36 Contest Type: Public Start Time: 2016-03-04 13:00:00 Contest Statu ...

随机推荐

  1. CentOS7.x 通过mail命令发,使用465端口(smtps协议)发送邮件

    #创建证书mkdir -p /root/.certs/echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CE ...

  2. unity postprocessing stack v2的优化

    今天做到33ms了 从45ms 到33ms 后处理占20ms 优化后8ms 去掉两次blit fast mode layer 去掉UI camera 用overlay 层级用sortingorder ...

  3. Hadoop之Storm基础

    1.离线计算是什么 离线计算:批量获取数据,批量传输数据,周期性批量计算数据,数据展示 代表技术:sqoop批量导入数据,hdfs批量存储数据,mapreduce批量计算数据,hive批量计算数据,* ...

  4. docker实战——Docker本地私有镜像仓库Harbor搭建及配置

    Harbor介绍 Docker容器应用的开发和运行离不开可靠的镜像管理,虽然docker官方提供了公共的镜像仓库(Docker Hub),但是从安全和效率等方面考虑,部署我们私有环境内的Registr ...

  5. pthread_barrier_init,pthread_barrier_wait简介(转)

    pthread_barrier 系列函数在<pthread.h>中定义,用于多线程的同步,它包含三个函数: --pthread_barrier_init() --pthread_barri ...

  6. 【Python3 爬虫】11_报错No module named 'requests'

    从网上下载了一段源码,执行过程中报错: No module named 'requests' 一看英文就明白是咋回事了~ 是由于:没有模块requests 解决方案 打开cmd,在窗口运行命令:pip ...

  7. Kubernetes使用prometheus+grafana做一个简单的监控方案

    前言 本文介绍在k8s集群中使用node-exporter.prometheus.grafana对集群进行监控.其实现原理有点类似ELK.EFK组合.node-exporter组件负责收集节点上的me ...

  8. Vue 全家桶 + Electron 开发的一个跨三端的应用

    代码地址如下:http://www.demodashi.com/demo/11738.html GitHub Repo:vue-objccn Follow: halfrost · GitHub 利用 ...

  9. tcp/ip --IP:网际协议

    1.概述      IP是TCP/IP协议族中最为核心的协议.所有的TCP,UDP,ICMP,IGMP数据都以IP数据报格式传输.      IP提供不可靠,无连接的数据报传送服务. 不可靠:它不能保 ...

  10. jQuery校验 表单验证

    官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...