zoukankan      html  css  js  c++  java
  • hdu2072

    注意输入全是0的情况。

    #include <stdio.h>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    bool cmp(char a[],char b[]){
        return ( strcmp(a,b)>0 );
    }
    int main(){
        char str[100000];
        char *res[100000];
        int i,cnt,l;
        int RES;
        int sign;
        while(NULL!=gets(str)){
            cnt=0;
            l=strlen(str);
    
            if( strcmp(str,"#")==0 ) break;
            strcat(str," ");
            sign=0;
            for(i=l-1;i>=0;--i){
                if(sign==0&&str[i]!=' '&&str[i+1]==' '){
                    str[i+1]='';
                    sign=1;
                }
                if(sign==1){
                    if(i==0&&str[i]!=' '){
                        res[cnt]=&str[i];
                        sign=0;
                        cnt++;
                    }
                    if(str[i]!=' ') continue;
                    if(str[i]==' '){
                        res[cnt]=&str[i+1];
                        sign=0;
                        cnt++;
                    }
                }
    
            }
            sort(res,res+cnt,cmp);
            RES=1;
            RES=RES<cnt?RES:cnt;
            for(i=1;i<cnt;++i){
                if( strcmp(res[i],res[i-1])==0  ) continue;
                else RES++;
            }
    
            printf("%d
    ",RES);
    
        }
        return 0;
    
    }
  • 相关阅读:
    Python 递归
    Python 面向过程编程
    Python 协程函数
    Python-第三方库requests详解
    Python 三元表达式
    linux copy
    centos 安装软件
    mysql 权限
    mysql 权限 备份
    android 开发
  • 原文地址:https://www.cnblogs.com/symons1992/p/3414709.html
Copyright © 2011-2022 走看看