hdu_5099 理解题意要求即可

本文介绍了一个C++程序,该程序通过一系列自定义函数实现两个特定格式字符串的比较,并根据比较结果输出相应的符号指示大小关系。文章详细展示了如何读取输入、解析字符串以及使用条件判断进行字符和整数部分的逐项比较。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char str1[7],str2[7];
void f(int a,int b)
{
    if(a<b) printf("<");
    else if(a>b) printf(">");
    else printf("=");
}
void g(char a,char b)
{
    if(a<b) printf("<");
    else if(a>b) printf(">");
    else printf("=");
}
int main()
{
   int t,kcase=1;
   scanf("%d",&t);
   while(t--)
   {
     scanf("%s%s",str1,str2);
     printf("Case %d: ",kcase++);
     if(str1[0]<str2[0]){printf("< ");}
     else if(str1[0]>str2[0]){printf("> ");}
     else {printf("= ");}
     int s1=(str1[3]-'0')*10+(str2[4]-'0'),s2=(str2[3]-'0')*10+(str2[4]-'0');
     if(str1[1]!=str2[1])
     {
         if(str1[2]<str2[2]){printf("<");}
         else if(str1[2]==str2[2]){f(s1,s2);}
         else {printf(">");}
     }
     else
     {
         if(str1[2]<str2[2]){printf("<");}
         else if(str1[2]==str2[2])
         {
             if(s1==s2) g(str1[5],str2[5]);
             else f(s1,s2);
         }
         else {printf(">");}
     }
     printf("\n");
   }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值