Comparison of Android versions(strcmp的应用)
Description
The first letter is the code name of the release family, e.g. F is Froyo. The code names are ordered alphabetically. The latest code name is K (KitKat).
The second letter is a branch code that allows Google to identify the exact code branch that the build was made from, and R is by convention the primary release branch.
The next letter and two digits are a date code. The letter counts quarters, with A being Q1 2009. Therefore, F is Q2 2010. The two digits count days within the quarter, so F85 is June 24 2010.
Finally, the last letter identifies individual versions related to the same date code, sequentially starting with A; A is actually implicit and usually omitted for brevity.
Please develop a program to compare two Android build numbers.
Input
Each test case consists of a single line containing two build numbers, separated by a space character.
Output
● Print "<" if the release of the first build number is lower than the second one;
● Print "=" if the release of the first build number is same as he second one;
● Print ">" if the release of the first build number is higher than the second one.
Continue to output the result of date comparison as follows:
● Print "<" if the date of the first build number is lower than the second one;
● Print "=" if the date of the first build number is same as he second one;
● Print ">" if the date of the first build number is higher than the second one.
If two builds are not in the same code branch, just compare the date code; if they are in the same code branch, compare the date code together with the individual version.
Sample Input
Sample Output
1、比较两个字符串的第一个字母的大小;
2、如果两个字符串的第二个字母不同就比较接下来的三个字母的大小,如果第二个字母相同就比较剩余的四个字母!
就是strcmp的应用
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,j,k,m;
char s1[],s2[],a[],b[];
scanf("%d",&n);
getchar();
for(i=; i<=n; i++)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(s1,,sizeof(s1));
memset(s2,,sizeof(s2));
scanf("%s %s",s1,s2);
printf("Case %d: ",i);
if(s1[]==s2[])
{
printf("= ");
}
else if(s1[]>s2[])
{
printf("> ");
}
else if(s1[]<s2[])
{
printf("< ");
}
k=;
m=;
if(s1[]==s2[])
{
for(j=; j<=; j++)
{
a[k++]=s1[j];
b[m++]=s2[j];
a[k]='\0';
b[m]='\0';
}
}
else
{
for(j=; j<=; j++)
{
a[k++]=s1[j];
b[m++]=s2[j];
a[k]='\0';
b[m]='\0';
}
}
if(strcmp(a,b)==)
printf("=");
else if(strcmp(a,b)<)
{
printf("<");
}
else if(strcmp(a,b)>)
{
printf(">");
}
printf("\n");
}
return ;
}
Comparison of Android versions(strcmp的应用)的更多相关文章
- HDU5099——Comparison of Android versions(简单题)(2014上海邀请赛重现)
Comparison of Android versionsProblem DescriptionAs an Android developer, itˇs really not easy to fi ...
- 模拟 HDOJ 5099 Comparison of Android versions
题目传送门 /* 题意:比较型号的大小 模拟:坑点在长度可能为5,此时设为'A' */ #include <cstdio> #include <algorithm> #incl ...
- HDOJ 5099 Comparison of Android versions 坑题
现场赛的时候错了十四次. . ... Comparison of Android versions Time Limit: 2000/1000 MS (Java/Others) Memory L ...
- hdoj-5099-Comparison of Android versions
Comparison of Android versions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- The YubiKey -- COMPARISON OF VERSIONS
COMPARISON OF YUBIKEY VERSIONS BASICSTANDARD & NANO BASICEDGE & EDGE-N PREMIUMNEO & NE ...
- Android官方文档翻译 十五 3.3Supporting Different Platform Versions
Supporting Different Platform Versions 支持不同的平台版本 This lesson teaches you to 这节课教给你 Specify Minimum a ...
- Android Platform Guide
This guide shows how to set up your SDK environment to deploy Cordova apps for Android devices, and ...
- Android Hook框架adbi源码浅析(一)
adbi(The Android Dynamic Binary Instrumentation Toolkit)是一个Android平台通用hook框架,基于动态库注入与inline hook技术实现 ...
- android hook 框架 ADBI 如何实现so注入
Android so注入-libinject2 简介.编译.运行 Android so注入-libinject2 如何实现so注入 Android so注入-Libinject 如何实现so注入 A ...
随机推荐
- 06JavaScript变量
JavaScript 变量 变量是用于存储信息的"容器". var x=5; var y=6; var z=x+y; 就像代数那样 x=5 y=6 z=x+y 在代数中,我们使用字 ...
- TinyMCE插件:Filemanager [4.x-6.x] 文件名统一格式化
上传图片程序(filemanager/upload.php) 在if (!empty($_FILES) && $upload_files)中上传图片时,在文件正式上传至服务器前,有一次 ...
- thinkphp中的大字母的意思
ThinkPHP 单字母函数 A() 内部实例化控制器 D() 实例化自定义模型类 M() 实例化一个基础模型类 R() 调用某个控制器的操作方法 L() 启用多语言的情况下,设置和获取当前的语言定义 ...
- MFC非模态添加进程控件方法一(线程方法)
由于非模态对话框的自己没有消息循环,创建后无法进行消息处理.需要和父窗口共用消息循环.如果单独在子窗口进行控件由于自己没有单独的消息循环,更新是无法进行的. 如果在父窗口更新控件会造成程序假死.如以下 ...
- Python爬虫系列 - 初探:爬取新闻推送
Get发送内容格式 Get方式主要需要发送headers.url.cookies.params等部分的内容. t = requests.get(url, headers = header, param ...
- 解决 Node.js 错误 Error:listen EADDRINUSE
第一次尝试 node.js 中的 express 框架,写了第一个 js 文件之后,在 WebStorm 运行,到游览器刷新,成功运行. 又创建一个 js 文件,写的是静态路由的访问,结果出现了 Er ...
- 笔记Equals的位置区别
String name=“add”: //值相同或不同时,效果相同 boolean flay=name.equals("add"): boolean flay2="add ...
- 全国各大城市Uber客服联系方式(电话、邮箱、微博)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- Java 数字用二进制表示,以及原码,反码,补码、负数的二进制表示
首先我们要对原码.反码和补码有个了解: 1.所谓原码就是二进制定点表示法,即最高位为符号位,"0"表示正,"1"表示负,其余位表示数值的大小. 2.反码表示法规 ...
- 4、Java并发编程:synchronized
Java并发编程:synchronized 虽然多线程编程极大地提高了效率,但是也会带来一定的隐患.比如说两个线程同时往一个数据库表中插入不重复的数据,就可能会导致数据库中插入了相同的数据.今天我们就 ...