zoukankan      html  css  js  c++  java
  • HDOJ1073(gets 应用)

    练习操作字符串的好题。

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    const int SIZE=5000+16;
    
    void fun_in(char s[])
    {
        char a[SIZE]={''};
        while(scanf("%s",a),strcmp(a,"START"));
        
        while(gets(a),strcmp(a,"END"))//精华 如果直接输入回车则a[0]为'', gets()以回车作为结束输入 scanf()以空格作为结束输入
    {
    if(a[0]!='') strcat(s,a); else strcat(s," "); } } void clean(char s[]) { char a[SIZE]={''}; int k=0; for(int i=0;s[i];i++) { if(s[i]==' '||s[i]==' '||s[i]==' ') continue; a[k++]=s[i]; } strcpy(s,a); } const char* fun_out(char s1[],char s2[]) { if(strcmp(s1,s2)==0) return "Accepted"; clean(s1),clean(s2); if(strcmp(s1,s2)==0) return "Presentation Error"; return "Wrong Answer"; } int main() { int T; scanf("%d",&T); getchar(); while(T--) { char s1[SIZE]={''}; char s2[SIZE]={''}; fun_in(s1),fun_in(s2); printf("%s ",fun_out(s1,s2)); } return 0; }
  • 相关阅读:
    C++ 类
    百练3383:Cell Phone Network
    百练4092:牛仔裤
    百练4091:最近餐馆
    百练4090:超级备忘录
    百练2868:牛顿迭代
    百练2812:恼人的青蛙
    百练2805:正方形
    bzoj1856 [Scoi2010]字符串
    bzoj2096 [Poi2010]Pilots
  • 原文地址:https://www.cnblogs.com/program-ccc/p/4696277.html
Copyright © 2011-2022 走看看