HDU 1062 Text Reverse
2011-05-04 09:49
309 查看
这题一水题 .... 据说可以用函数做 ( strtok ) ,没用,没看懂,自己写了一个.. 水果,不过记住中间有很多空格要原样输出......还有把字符串分开后,在每个后面都得赋值ASCII为0额
#include<stdio.h> #include<string.h> int n,c; char str[1005],ch[1005][1005]; void sort( ) { int i = 0; while( str[i] ) { int j = 0; while( str[i] == ' ' ) ch[c][j++] = str[i++]; ch[c][j] = 0; ++c; j = 0; while( str[i] && str[i] != ' ' ) ch[c][j++] = str[i++]; ch[c][j] = 0; ++c; } } void change( ) { for( int i = 0; i < c; ++i ) { int len = strlen( ch[i] ); for( int p = len - 1, q = 0; p > q; --p,++q ) { char s = ch[i][p]; ch[i][p] = ch[i][q]; ch[i][q] = s; } printf( "%s",ch[i] ); } } int main( ) { scanf( "%d%*c",&n ); while( n-- ) { c = 0; gets( str ); sort( ); change( ); puts( "" ); } return 0; }
相关文章推荐
- hdu 1062 Text Reverse
- [置顶]-hdu-1062-Text Reverse
- hdu 1062 Text Reverse
- hdu1062——Text Reverse
- HDU 1062 Text Reverse(水题,字符串处理)
- HDU1062 Text Reverse
- hdu 1062 Text Reverse(字符串处理,简单模拟)
- hdu 1062 Text Reverse 字符串
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- HDU1062 Text Reverse
- HDU 1062 Text Reverse 水题 字符串处理
- hdu 1062 Text Reverse
- hdu 1062 Text Reverse
- hdu1062 - Text Reverse
- Hdu---Text Reverse---1062 java版的注意
- HDU 1062 Text Reverse(水题)
- HDU——1062 Text Reverse
- HDU 1062 Text Reverse
- HDU 1062 Text Reverse (模拟)