• 2022-05-26
    以下函数的功能是连接两个字符串,请完善程序。void str_cat(char str1[ ], char str2[ ], char str[ ]){ int i,j; for(i=0;str1[i]!= '0';i++) str[i]=str1[i]; for(j=0;str2[j]!='0';j++) str[i++]=str2[j]; ; }[/i][/i][/i]
    A:
  • A

    内容

    • 0

      对于如下C程序:#include &#91;stdio.h&#93; void Func (char *); int main() { char str&#91;20&#93;; scanf ("%s", str); Func(str); printf ("%s\n", str);} void Func(char *str) { int i = 0; int index = 0; char temp; while (str&#91;index&#93; != '\0'){ index++; } for (i = 0; i < index/2 ; i++){ temp = str[i]; str[i] = str&#91;index - 1 - i&#93;; str&#91;index - 1 - i&#93; = temp; }}如果输入为“abcd”,则输出为:[/i][/i] A: abcd B: dcba C: dcdc D: abab

    • 1

      1. 写出下面函数实现的功能是什么? char *maxstr(char *str[],int n) {int i,len,j=0; len=strlen(str[j]); for(i=1;ilen) {j=i;len=strlen(str[i]) ;} return str[j]; }

    • 2

      当运行以下程序时,输入abcd,程序的输出结果是:【1】。#include #include insert(char str&#91;&#93;){int i; i=strlen(str); while(i&gt;0) {str&#91;2*i&#93;=str[i];str&#91;2*i-1&#93;='*';i--;} printf("%s\n",str);}void main(){char str&#91;40&#93;; scanf("%s",str); insert(str);}[/i]

    • 3

      下列程序运行时输入:This_is_a_C_Program! 运行结果为: #include #include int main(void) { char str[81], a[81], b[81]; int n, i, j=0, k=0; gets( str ); n=strlen( str ); for ( i=0; i { if ( i%2==0 ) a[j++] = str[i]; if ( i%3==0 ) b[k++] = str[i]; } a[j] = b[k] = ''; puts( a ); puts( b ); return 0; }

    • 4

      本程序的函数ver是使输入的字符串按反序存放,在主函数中输入和输出字符串。 main() { char str[100]; scanf("%s",str); ver(str); printf("%s\n",str); } ver( 【1】 ) char str[] { char t; int i,j; for(i=0,j=strlen(str);i str[i]=str[j-1]  str[j-1]=t