更多"有以下程序: void swap(char *x,char *y) "的相关试题:
[单项选择]有以下程序:
#include<stdio.h>
void swap(char *x, char *y)
char t;
t=*x; *x=*y; *y=t;
main( )
char *s1="abc", *s2="123";
swap(s1, s2); printf("%s, %s/n", s1, s2);
程序执行后的输出结果是( )。
A. abc, 123
B. 123, abc
C. 1bc, a23
D. 321, cba
[单项选择]有以下程序:
#include <stdio.h>
void swap(char *x, char *y)
{ char t;
t=*x; *x=*y; *y=t;
}
main( )
{ char *s1="abc", *s2="123";
swap(s1, s2); printf("%s, %s/n", s1, s2);
}
程序执行后的输出结果是______。
A. 321,cba
B. abc,123
C. 123,abc
D. 1bc,a23
[多项选择]简单应用题
请编写函数void swap(int *px,int *py) 与void swap(int &px,int &py),实现主程序中变量a和b值的交换。
输出结果如下:
3 2
2 3
注意:部分源程序已存在文件test5_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数相应的花括号中填写若干语句。
文件test5_2.cpp的内容如下:
#include
void swap(int *px,int *py)
{
/***1***/
}
void swap(int &px,int &py)
{
/***2***/
}
void main( )
{
int a=2,b=3;
swap(a,b);
cout<
[简答题]请编写函数void swap(int *px,int *py)与void swap(int &px,int &PY),实现主程序中变量a和b值的交换。
输出结果如下:
3 2
2 3
注意:部分源程序已存在文件test5_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数相应的花括号中填写若干语句。
文件test5_2.cpp的内容如下:
#include<iostream.h>
void swap(int *px,int *py)
/***1***/
void swap(int &px,int &PY)
/***2**/
void main( )
int a=2,b=3;
swap(a,b);
cout<<a<<" "<<b<<endl;
swap(&a,&b);
cout<<a<<" "<<b<<endl;
[单项选择]有以下程序:
void swap1(int c[ ])
{ int t;
t=c[0];c[0]=c[1];c[1]=t; }
void swap2(int c0,int c1)
{ int t;
t=c0;c0=c1;c1=t; }
main( )
{ int a[2]={3,5},b[2]={3,5};
swap1(a); swap2(b[0],b[1]);
printf(“%d %d %d %d/n”,a[0],a[1],b[0],b[1]); }
其输出结果是( )。
A. 5 3 5 3
B. 5 3 3 5
C. 3 5 3 5
D. 3 5 5 3
[填空题]以下程序运行后的输出结果是【 】。
void swap(int x,int y)
{ int t;
t=x;x=y;y=t;printf("%d%d",x,y);
}
main( )
{ int a=3,b=4;
swap(a,b);pintf(("%d%d",a,b);
}
[单项选择]有以下程序:
#include <stdio.h>
void swap1(int c[])
int t;
t=c[0]; c[0]=c[1]; c[1]=t;
void swap2(int c0,int c1)
int t;
t=c0; c0=c1; c1=t;
main( )
int a[2]=3,5,b[2]=3,5;
swap1(a); swap2(b[0],b[1]);
printf("%d%d%d%d/n",a[0],a[1],b[0],b[1]);
其输出结果是()。
A. 5 3 5 3
B. 5 3 3 5
C. 3 5 3 5
D. 3 5 5 3
[单项选择]以下程序的输出结果是( )。
#include <stdio.h>
void swap(int*a, int *b)
int*t;
t=a; a=b; b=t;
main( )
int i=3, j=5, *p=&i, *q=&j;
swap(p, q); printf(1%d %d/n, *p, *q);
A. 23
B. 34
C. 35
D. 45
[单项选择]以下程序运行后的输出结果是
void swap(int x, int y)
int t;
t=x;x=y;y=t;
main( )
int a=15, b=16;
swap(a, b); printf("% d % d", a, b);
A. 15, 16
B. 16, 15
C. 15, 15
D. 16, 16
[单项选择]有以下程序:
void swap1(int c0[],int c1[])
{ int t;
t=c0[0]; c0[0]=c1[0]; c1[0]=t;
}
void swap2(int *c0,int *c1)
{ int t;
t=*c0; *c0=*c1; *c1=t;
}
main( )
{int a[2]={3,5}, b[2]={3,5};
swap1(a,a+1); swap2(&b[0],&b[1]);
printf("%d %d %d %d/n",a[0],a[1],b[0],b[1]);
}
程序运行后的输出结果是______。
A. 3 5 5 3
B. 5 3 3 5
C. 3 5 3 5
D. 5 3 5 3
[填空题]以下程序运行后的输出结果是 【13】 。
void swap(int x,int y)
{ int t;
t=x;x=y;y=t;printf("%d%d",x,y);
}
main( )
{ int a=3,b=4;
swap(a,b);pintf(("%d%d",a,b);
}
[单项选择]
有以下程序的输出结果是()
void swap1(int c[ ]) {
int t;
t=c[0];c[0]=c[1];c[1]=t;
}
void swap2(int c0,int c1) {
int t;
t=c0;c0=c1;c1=t;
}
main( ) {
int a[2]={3,5},b[2]={3,5};
swap1(a); swap2(b[0],b[1]);
printf(“%d %d %d %d/n”,a[0],a[1],b[0],b[1]);
}
A. 5 3 5 3
B. 5 3 3 5
C. 3 5 3 5
D. 3 5 5 3
[单项选择]有以下程序:
void swap1(int * a,int * b)
int* c=a;
a=b,b=c;
void swap2(int * a,int * b)
int c=* a;
* a=*b,*b=c;
main( )
int a=10,b=15;
swap 1(&a,&b) ;
printf("%d,%d,",a,b) ;
a=10,b=15;
swap 2(&a,&b) ;
printf("%d,%d",a,b) ;
其输出结果为 ()。
A. 15,10,10,15
B. 15,10,15,10
C. 10,15,10,15
D. 10,15,15,10
[填空题]以下程序的输出结果是______。
#include <stdio.h>
void swap(int *a, int *b)
int *t
t=a; a=b; b=t
main( )
int i=3,j=5,*p=&i,*q=&j;
swap(p,q); printf("%d %d/n",*p,*q);
[单项选择]以下程序运行后的输出结果是
void swap(int x,int y)
int t;
t=x;x=y;y=t;
main( )
int a=15,b=16;
swap(a,b);printf(“%d%d”,a,b);
A. 15,16
B. 16,15
C. 15,15
D. 16,16