大整数比较
发布日期:2021-06-29 02:23:35 浏览次数:2 分类:技术文章

本文共 924 字,大约阅读时间需要 3 分钟。

#include 
#include
#include
#include
#include
#include
using namespace std;int f(char* a, char* b){ int l_a = strlen(a), l_b = strlen(b); if (a[0] == '-' && b[0] != '-')//a<0 ,b>0 { return -1; } else if (a[0] == '-' && b[0] == '-')//a<0 ,b<0 { if (l_a == l_b) { if (strcmp(a, b) == 1)return -1; else if (strcmp(a, b) == 0)return 0; else return 1; } else if (l_a < l_b)return 1; else return -1; } else if (a[0] != '-' && b[0] != '-')//a>0,b>0 { if (l_a == l_b) { if (strcmp(a, b) == 1)return 1; else if (strcmp(a, b) == 0)return 0; else return -1; } else if (l_a < l_b)return -1; else return 1; } else if (a[0] != '-' && b[0] == '-')//a>0,b<0 { return 1; }}int main(){ int t; cin >> t; while (t--) { char a[100], b[100]; cin >> a >> b; if (f(a, b) == 1)cout << ">" << endl; else if (f(a, b) == 0)cout << "=" << endl; else if (f(a, b) == -1)cout << "<" << endl; }}

转载地址:https://blog.csdn.net/YYDS777/article/details/115149840 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:TKK 20-21(2)第3次线上赛
下一篇:JGOJ P1507数组的贡献值

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月19日 09时34分35秒