历年真题
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】
(13)以下程序的功能是:将值为三位正整数的变量x中的数值按照个位、十位、百位的顺序拆分并输出。请填空。 #include<stdio.h> main()
{int x=256;
printf(“%d-%d-%d\n”,【13】,x/10%10,x/100); }
(14)以下程序用以删除字符串中所有的空格,请填空。 #include<stdio.h> main()
{char[100]={“Our teacher teach c language!”};int i,j; for(i=j=0;s[i]!=‘\0’;i++)
if(s[i]!=‘ ’) {s[j]=s[i];j++;} s[j]=【14】;
printf(“%s\n”,s); }
(15)以下程序的功能是:借助指针变量找出数组元素中的最大值及其元素的下标值。请 填空。
#include<stdio.h> main()
{int a[10],*p,*s;
for(p=a;p-a<10;p++) scanf(“%d”,p);
for(p=a,s=a;p-a<10;p++) if(*p>*s) s=【15】; printf(“index=%d\n”s-a); }