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 ...
随机推荐
- 剑指Offer_编程题之从尾到头打印链表
题目描述 输入一个链表,从尾到头打印链表每个节点的值.
- ORACLE GOLDEN GATE oracle同步数据至kafka
一.服务器信息 ip 软件版本 ogg版本 软件包 操作系统版本 OGG安装路径 10.1.50.52 源 oracle11.2.0.4 12.2.0.1.1 V100692-01.zip cen ...
- C/C++中的malloc、calloc和realloc
1. malloc 原型:extern void *malloc(unsigned int num_bytes); 头文件:Visual C++6.0中可以用malloc.h或者stdlib.h 功能 ...
- Python3练习:对员工信息文件,实现增删改查操作
1.练习要求: 2.数据文件(data_staff.txt) 1,Alex Li,22,13651054684,运维,2013-02-04 2,Jack Wang,20,13312331232,HR, ...
- centos7安装mysql5.7.18笔记
重装了一下系统,装了centos7,但是centos7下默认没有安装mysql,有MariaDB数据库,网上的解释是: “MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用 ...
- 用elk+filebeat监控容器日志
elk 为 elasticsearch(查询搜索引擎),logstash(对日志进行分析和过滤,然后转发给elasticsearch),kibana(一个web图形界面用于可视化elasticsea ...
- 使用bison和yacc制作脚本语言(2)
我们先来想一下语法 一般脚本语言不需要定义类型直接在赋值的时候确定 我们主要考虑一下变量的类型 a = 1; b = 1.1; c = "str"; 一般来讲,我们使用这三种类型, ...
- 手搓一个C语言简单计算器。
#include <stdio.h> void xing(int shu); void biaoti(int kong,char * title); void zhuyemian(char ...
- flash读写学习笔记与spi接口及简单测试验证(三)
FPGA中的视频图像资源,以及想要永久存储的程序都是要存储在flash中,flash是FPGA一个不可缺少的部分,flash的种类有很多,根据winbond公司的128Mbit Qual SPI接口的 ...
- 剑指offer题目系列三(链表相关题目)
本篇延续上一篇剑指offer题目系列二,介绍<剑指offer>第二版中的四个题目:O(1)时间内删除链表结点.链表中倒数第k个结点.反转链表.合并两个排序的链表.同样,这些题目并非严格按照 ...