2054A==B?hdu
来源:互联网 发布:网络电影榜单 编辑:程序博客网 时间:2024/06/10 07:36
自己做这道题第一次用到了strchr这个函数;
strchr函数原型:extern char *strchr(const char *s,char c);查找字符串s中首次出现字符c的位置。
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 61130 Accepted Submission(s): 9517
Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
Input
each test case contains two numbers A and B.
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
Sample Input
1 2
2 2
3 3
4 3
2 2
3 3
4 3
Sample Output
NO
YES
YES
NO
YES
YES
NO
AC代码:
#include<stdio.h>
#include<string.h>
#define M 1000000
char s[M];
char p[M];
int fun(char *p)
{
int n,i,j;
n=strlen(p);
if(strchr(p,'.')!=NULL)
{
for(i=n-1;p[i]=='0';i--);
if(p[i]=='.')
p[i]='\0';
else
p[i+1]='\0';
}
for(i=0;p[i]=='0'&&p[i+1]!='\0';i++);
return i;
}
int main()
{
while(~scanf("%s %s",s,p))
{
int m,k,t;
int i,j;
for(i=fun(s),j=fun(p);s[i]!='\0'&&p[j]!='\0';i++,j++)
{
if(s[i]!=p[j])
{
//printf("NO\n");
break;
}
}
if(s[i]=='\0'&&p[j]=='\0')
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
#include<string.h>
#define M 1000000
char s[M];
char p[M];
int fun(char *p)
{
int n,i,j;
n=strlen(p);
if(strchr(p,'.')!=NULL)
{
for(i=n-1;p[i]=='0';i--);
if(p[i]=='.')
p[i]='\0';
else
p[i+1]='\0';
}
for(i=0;p[i]=='0'&&p[i+1]!='\0';i++);
return i;
}
int main()
{
while(~scanf("%s %s",s,p))
{
int m,k,t;
int i,j;
for(i=fun(s),j=fun(p);s[i]!='\0'&&p[j]!='\0';i++,j++)
{
if(s[i]!=p[j])
{
//printf("NO\n");
break;
}
}
if(s[i]=='\0'&&p[j]=='\0')
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
0 0
- HDU 2054 A == B ?
- HDU 2054 A==B
- hdu acm 2054 A == B ?
- hdu - 2054 - A == B ?
- hdu 2054 A == B ?
- Hdu 2054 - A == B ?
- hdu 2054 A == B ?【JAVA】
- hdu 2054 A==B?
- HDU 2054 A == B ?
- hdu 2054 A==B?
- hdu 2054 A == B ?
- HDU--2054 -- A == B ? [字符串]
- HDU 2054 - A == B ?
- HDU 2054 A == B ?
- HDU-2054 A==B?
- HDU 2054 A==B? 大数
- HDU 2054 A == B ?
- hdu 2054A == B ?
- ViewPager 详解(一)---基本入门
- 布隆过滤器(Bloom Filter)
- STL--B - Hardwood Species
- ural 1008 Image Encoding bfs
- Codeforces Round #260 (Div. 2)A. Laptops
- 2054A==B?hdu
- HDU 1028 Ignatius and the Princess III
- uvaLive 6667 Longest Chain ( splay )
- ios中的字面量语法
- java
- ural 1005 Stone Pile 01背包或dfs
- JavaScript学习 jquery14 渐变动画
- HSSFWorkBooK用法
- 使用泛型的注意事项