题库 信息学奥赛题库 题目列表 看程序写结果:#include "ctype.h" #includ...
填空题

看程序写结果:

#include "ctype.h" #include "stdio.h" void expand( char s1[], char s2[] ) { int i, j, a, b, c; j = 0; for ( i = 0; (c = s1[i]) != '\0'; i++ ) if ( c == '-' ) { a = s1[i - 1]; b = s1[i + 1]; if ( isalpha( a ) && isalpha( b ) || isdigit( a ) && isdigit( b ) ) /*函数 isalpha(a) 用于判断字符 a 是否为字母,isdigit(b) 用于判断字符 b 是否为数字,如果是,返回 1,否则返回 0 */ { j--; do s2[j++] = a++; while ( tolower( a ) < tolower( s1[i + 1] ) ); } /*函数 tolower(a) 的功能是当字符 a 是大写字母,改为小写,其余情况不变*/ else s2[j++] = c; }else s2[j++] = c; s2[j] = '\0'; } int main() { char s1[100], s2[300]; printf( "input s1:" ); gets( s1 ); expand( s1, s2 ); printf( "%s\n", s2 ); }

输入:wer2345d-h454-82qqq

题目信息
2007年 初赛
-
正确率
0
评论
49
点击