码迷,mamicode.com
首页 > 其他好文 > 详细

统计一行的不重复的单词字符个数

时间:2016-06-11 18:52:03      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:


源代码如下:
//输入# 号结束

#include<stdio.h> #include<stdlib.h> #include<string.h> char str[500000]; char ss[10000][30] ; int des[10000]; int main( ) { while( gets( str ) && str[0] != # ) { memset( des , 0 , sizeof( des ) ) ; int count = 0 ; int i = 0 ; char *p = strtok( str , " " ); while( p != NULL ) { strcpy( ss[i++] , p ) ; p = strtok( NULL , " " ) ; } for( int j = 0 ; j < i ; j++ ) { for( int k = j+1 ; k < i ; k++ ) if( strcmp( ss[j] , ss[k] ) == 0 )des[k] = 1; } for( int j = 0 ; j < i ; j++ ) if( des[j]== 0 ) count++ ; printf("%d\n" , count ) ; } return 0;

 

统计一行的不重复的单词字符个数

标签:

原文地址:http://www.cnblogs.com/ly-rabbit-wust/p/5575661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!