试题35
有以下程序
#include <stdio.h>
#include <string.h>
void fun(char *w,int m)
{ char s, *p1, *p2;
p1=w; p2=w+m-1;
while(p1<p2){s=*p1; *p1=*p2; *p2=s; p1++; p2- -;}
}
main()
{ char a[]=”123456”;
fun(a, strlen(a)); puts(a);
}
程序运行后的输出结果是()
A.654321
B.116611
C.161616
D.123456
第1题:
有以下程序:
include <iostream>
using namespace std;
const xnt N=5;
int fun(char *s,char a,int n)
{
int j;
*s=a;j=n;
while(a<s[j])
j--;
return j;
}
int main()
{
char s[N+1];
int k;
第2题:
阅读下列程序:
include<iostream.h>
void fun(int n)
{
int x(5);
static int y(10);
if(n>0)
{
++x;
++y;
cout<<x<<","<<y<<endl;
}
}
void main()
int m(1);
fun(m);
}
则该程序的输出结果是______。
第3题:
阅读下面程序:
include<iostream.h>
void fun(int n)
{
int x(5);
static int y(10);
if(n>0)
{
++x;
++y;
cout<<x<<","<<y<<end1;
}
}
void main()
{
int m(1);
fun(m);
}
则该程序的输出结果是______。
第4题:
下面程序的运行结果为_____。
include<iostream.h>
void fun(int x=0,int y=0)
{
cout < < x < < y;
}
void main( )
{
fun(5) ;
}
第5题:
有以下程序 #include <stdio.h> int fun(char s[]) { int n=O; while(*s<='9'&&*s>='0') { n=10*n+*s-'0'; s++; } return (n); } main() { char s[10]={ '6', '1', '*', '4', '*', '9', '*', '0', '*'}; printf("%d\n",fun(s)); }
A.9
B.61490
C.61
D.5
第6题:
以下程序的运行结果是______。
include<iostrearn.b>
fun(int a,int b)
{
int m=0,i=2;
i+=m+1;
m=i+a+b;
return m;
}
void main()
{int k=4,m=1,p;
p=fun(k,m);cout<<p<<end1;
}
第7题:
以下程序的输出结果是( )。
include<stdio.h>
void fun(int x)
{ if(x/2>0)fun(x/2);
printf("%d",x);
}
main()
{fun(3);printf("\n");
}
第8题:
下列程序的输出结果是______。
include<iostream.h>
include<string.h>
using namespace std;
void fun(const char*s,char &C) {c=s[strlen(s)/2];}
int main()
{
char str[]="ABCDE";
char ch=str[1];
fun(str,ch);
cout<<ch;
return 0;
}
第9题:
有以下程序 #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 0--i+l; 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[5][10]= {"bcc", "bbcc", "xy", "aaaacc", "aabcc" }; fun(ss, 5); printf("%s,%s\n", ss[0],ss[4]); } 程序的运行结果是
A.xy, aaaacc
B.aaaacc,xy
C.xcc,aabcc
D.acc,xabcc
第10题:
有以下程序 #include <stdio.h> void fun(char **p) { ++p; printf("%s\n",*p); } main() { char *a[]={"Moming","Afternoon","Evening","Night"}; fun(a); } 程序的运行结果是
A.Afternoon
B.fternoon
C.Morning
D.orning