HDU 2072 单词数
这里跟前面两个字符串处理差不多,http://www.cnblogs.com/Lvsi/archive/2011/05/03/2035640.html http://www.cnblogs.com/Lvsi/archive/2011/05/04/2036156.html
#include<stdio.h> #include<string.h> int n; char str[10005],ch[1005][1005]; void sort( ) { int i = 0; while( str[i] ) { if( str[i] == ' ' ) { ++i; continue; } int j = 0; while( str[i] && str[i] != ' ' ) ch[n][j++] =str[i++]; ch[n][j] = 0; int f = 1; for( int j = 0; j < n; ++j ) if( !strcmp( ch[j],ch[n] ) ) { f = 0; break; } if( f ) ++n; } } int main( ) { while( gets( str ) ) { n = 0; if( str[0] == '#' ) break; sort( ); printf( "%d\n",n ); } return 0; }
本人还是新手 ,转载请注明来自Lvsi‘s home