[试题]

( 12 ) 有以下程序

#include <stdio.h>

#include <string.h>

void fun ( char *str )

{ char temp;int n,i;

n=strlen ( str ) ;

temp=str[n-1];

for ( i=n-1;i>0;i-- ) str[i]=str[i-1];

str[0]=temp;

}

main ()

{ char s[50];

scanf ( " %s " ,s ) ; fun ( s ) ; printf ( " %s/n " ,s ) ;}

程序运行后输入: abcdef< 回车 > ,则输出结果是 ( 12 ) 。

参考答案与解析:

相关试题

( 37 )有以下程序#include <stdio.h>#include <s

[单选题]( 37 )有以下程序#include <stdio.h>#include <string.h>struct A{ int a; char b[10]; double c;};void f ( struct A t ) ;main (){ struct A a={1001, " ZhangDa " ,1098.0};f ( a ) ; printf ( " %d,%s,%6.1f/n " ,a.a,a.b,a.c ) ;}void f ( struct A t )

  • 查看答案
  • ( 37 )有以下程序#include <stdio.h>#include <s

    [单选题]( 37 )有以下程序#include <stdio.h>#include <string.h>struct A{ int a; char b[10]; double c;};void f ( struct A t ) ;main (){ struct A a={1001, " ZhangDa " ,1098.0};f ( a ) ; printf ( " %d,%s,%6.1f/n " ,a.a,a.b,a.c ) ;}void f ( struct A t )

  • 查看答案
  • ( 37 )有以下程序#include <stdio.h>#include <s

    [单选题]( 37 )有以下程序#include <stdio.h>#include <string.h>struct A{ int a; char b[10]; double c;};void f ( struct A t ) ;main (){ struct A a={1001, " ZhangDa " ,1098.0};f ( a ) ; printf ( " %d,%s,%6.1f/n " ,a.a,a.b,a.c ) ;}void f ( struct A t )

  • 查看答案
  • 有以下程序#include <stdio.h>#include <string.

    [单选题]有以下程序#include <stdio.h>#include <string.h>void fun(char s[][10],int n){ char t;int i,j;for(i=0;i<n-1;i++)for(j=i+1;j<n;j++)/* 比较字符串的首字符大小,并交换字符串的首字符 */if (s[i][0] > s[j][0]) {t=s[i][0];s[i][0]=s[j][0];s[j][0]=t;}}main(){ char ss[

  • 查看答案
  • 有以下程序#include <stdio.h>#include <string.

    [单选题]有以下程序#include <stdio.h>#include <string.h>typedef struct{ char name[9];char sex; float score[2]; } STU;STU f(STU a){ STU b={"Zhao",'m',85.0,90.0}; int i;strcpy(a.name,b.name);a.sex=b.sex;for(i=0;i<2;i++) a.score[i]=b.score[i];retur

  • 查看答案
  • 有以下程序#include <stdio.h>#include <stdlib.

    [单选题]有以下程序#include <stdio.h>#include <stdlib.h>int fun(int n){ int *p;p=(int*)malloc(sizeof(int));*p=n; return *p;}main(){ int a;a = fun(10); printf("%d/n",a+fun(10));}程序的运行结果是A.)0B.)10C.)20D.) 出错

  • 查看答案
  • 有以下程序#include <stdio.h>#include <string.

    [单选题]有以下程序#include <stdio.h>#include <string.h>main(){ char str[ ][20]={"One*World","One*Dream!"},*p=str[1];printf("%d,",strlen(p));printf("%s/n",p);}程序运行后的输出结果是A.)9,One*WorldB.)9,One*Dream !C.)10,One*Dream !D.)10,One*World

  • 查看答案
  • 有以下程序#include <stdio.h>#include <string.

    [单选题]有以下程序#include <stdio.h>#include <string.h>main(){ char a[10]="abcd";printf("%d,%d/n",strlen(a),sizeof(a));}程序运行后的输出结果是A.)7,4B.)4,10C.)8,8D.)10,10

  • 查看答案
  • 有以下程序#include <stdio.h>#include <stdlib.

    [单选题]有以下程序#include <stdio.h>#include <stdlib.h>int fun(int t){ int *p; p=(int*)malloc(sizeof(int)); *p=t; return *p;}main(){ int a; a = fun(8); printf("%d/n", a+fun(10));}程序的运行结果是A.0 B.10 C.18 D.出错

  • 查看答案
  • 有以下程序#include <stdio.h>#include <string.

    [单选题]有以下程序#include <stdio.h>#include <string.h>main( ){ printf("%d/n",strlen ("ATS/n012/1") ); }程序运行后的输出结果是A.)3B.)8C.)4D.)9

  • 查看答案
  • ( 12 ) 有以下程序#include <stdio.h>#include <