hdu2072

时间:2021-01-19 17:03:52

注意输入全是0的情况。

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
bool cmp(char a[],char b[]){
return ( strcmp(a,b)> );
}
int main(){
char str[];
char *res[];
int i,cnt,l;
int RES;
int sign;
while(NULL!=gets(str)){
cnt=;
l=strlen(str); if( strcmp(str,"#")== ) break;
strcat(str," ");
sign=;
for(i=l-;i>=;--i){
if(sign==&&str[i]!=' '&&str[i+]==' '){
str[i+]='\0';
sign=;
}
if(sign==){
if(i==&&str[i]!=' '){
res[cnt]=&str[i];
sign=;
cnt++;
}
if(str[i]!=' ') continue;
if(str[i]==' '){
res[cnt]=&str[i+];
sign=;
cnt++;
}
} }
sort(res,res+cnt,cmp);
RES=;
RES=RES<cnt?RES:cnt;
for(i=;i<cnt;++i){
if( strcmp(res[i],res[i-])== ) continue;
else RES++;
} printf("%d\n",RES); }
return ; }

相关文章