2010/05/21
| |
  这题实在无语,非常阴险,题目说的每组数据间的空行是输入空行,C中可以用getchar();
  我的C代码,题目还算简单,不过花了很长时间,很狡猾的题目:
  
  

#include<stdio.h>
#include<string.h>
void trim(char *str,char *p)
{
  if(strlen(str)!=0)
  {
    while(*str!='\0')
    {
      if(*str!=' ')
      {
        *p++=*str;
      }
      str++;
    }
  }
  *p='\0';
}
char *trans(char *str)
{
  char *p;
  p=str;
  while(*p!='\0')
  {
    if(*p>='A'&&*p<='Z')
    {
      *p=*p+32;
    }
    p++;
  }
  return str;
}
int main()
{
  int n;
  char s[10];
  scanf("%d",&n);
  gets(s); //读取无用的ENTER
  while(n--)
  {
    char str1[101],str2[101],str3[101],str4[101],*p,*q;
    gets(str1);
    gets(str2);
    p=str3;
    q=str4;
    trim(str1,p);
    trim(str2,q);
    p=trans(str3);
    q=trans(str4);
    if(strcmp(p,q)==0)
    {
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    getchar();
  }
}
    

    
Tags: ,
不指定 2010/05/21 14:37, wxxslt, 网站建设 » C/C++, 评论(0), 阅读(4202)
发表评论
表情
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]
               

 
Theme by Marshal. Powered by Bo-Blog 2.1.1 ReleaseCode detection by Bug.Center.Team