以下程序的功能是 : 通过函数 func 输入字符并统计输入字符的个数 。 输入时用字符 @ 作为输
#include <stdio.h>
long 【 14 】 ; /* 函数说明语句 */
main()
{ long n;
n=func(); printf("n=%ld\n",n);
}
long func()
{ long m;
for(m=0;getchar()!='@'; 【 15 】 );
return m;
}
#include <stdio.h>
long 【 14 】 ; /* 函数说明语句 */
main()
{ long n;
n=func(); printf("n=%ld\n",n);
}
long func()
{ long m;
for(m=0;getchar()!='@'; 【 15 】 );
return m;
}
编写一个函数,实现一个字符串的升序排序并输出排序后的字符串,字符串长度小于20。 程序运行结果如下: Input a string: friend↙ definr 在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 20 void mySort(char str[], int n) { int i, j, tmp; if (str == NULL || n <= 0) return; for (i="0;" ________; ++i) { (_________; j n; ++j) if (____________) tmp="str[i];" str[i]="str[j];" str[j]="tmp;" } int main() char str[n]; printf("input a string:\n"); gets(str); n="_________;" mysort(str, n); printf("%s", str); return 0;> A、第10行: i < n - 1 第12行: j = i + 1 第14行: str[i] > str[j] 第30行: strlen(str)
B、第10行: i < n 第12行: j = i + 1 第14行: str[i] <= str[j] 第30行: sizeof(str)> C、第10行: i <= n 第12行: j="i" 第14行: str[i]> str[j] 第30行: strlen(str)
D、第10行: i <= 1 n - 第12行: j="n" 第14行: str[i]> str[j] 第30行: strlen(str)-1
例如,若字符串中的内容为****A*BC*DEF*G*******,删除后,字符串中的内容则应当是A*BC*DEF*G。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include <conio.h>
void fun (char *a;int n ,int h ,int e)
{
}
main ( )
{
char s [81],*t,*f;
int m=0,tn=0, fn=0;
printf("Enter a string :\n");
gets (s);
t=f=s;
while (*t)
{t++;m++; } /*m为字符串的长度*/
t--; /*指针t指身字符串尾部*/
while (*t=='*')
{t--; tn++; }
/*指针t指向最后一个字母,tn统计尾部'*'的个数*/
while (*f=='*' )
{f++;fn++;}
/*指针f指向第一个字母,tn统计导'*'的个数*/
fun( s, m, fn, tn);
printf ("The string after deleted: \n");
puts (s);
}
输入两个字符串a,b,如果第一个字符串a中含有空格符,则用字符串b替换字符串a中的空格,否则保持a不变。最终得到替换后的新字符串c,并输出。要求: 1用gets函数得到从键盘输入的字符串; 2. 字符串a,b的长度最大为100,定义宏maxLength表示最大长度,新字符串c的最大长度为maxLength* maxLength 输入提示信息: "Input the first str:" "Input the second str:" 输出提示信息: "New str:" 输出格式:"%s" 程序运行示例1(有2个空格): Input the first str:abc 123 dd↙ Input the second str:YYY↙ New str:abcYYY123YYYdd 程序运行示例2(没有空格): Input the first str:abc↙ Input the second str:yy↙ New str:abc 程序运行示例3(有3个空格): Input the first str:abc 123↙ Input the second str:yy↙ New str:abcyyyyyy123
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!