有几道C++的难题,谁能帮帮我?

来源:百度知道 编辑:UC知道 时间:2024/06/15 14:59:41
下面是几道C++的题目,我新学,根本看不懂,已经看了一星期了,没头绪,又马上要考试了,各位大大帮帮忙吧。非常感谢。24小时在线等。

输出程序运行后的结果
1. #include
void main( ){
char *a[5]={"student","worker","cadre","soldier","peasant"}
char *p1,*p2;
p1=p2=a[0];
for (int i=0; i5;i++){
if(strcmp(a[i],p1)0) p1=a[i];
if(strcmp(a[i],p1)0) p2=a[i];
}
coutp1' 'p2endl;
}

#include
void wf(int x, int y){
x=x+y;
y=x+y;
cout"subs:""x,y="x","yendl;}
void main( ) {
int x=8 ,y=15;
cout"main:""x,y="x","yendl;
wf(x,y);
cout"main:""x,y="x","yendl;
}

#include
void main( ){
int a[10]={2,4,6,8,10,12,14,16,18,20}
for(int i=0;i10,i++){
coutsetw(5)*(a+i);
if((i=1)%4==0) coutendl;
}
}

写出函数的功能
1 bool WB(int a[ ],int x){

天天魔兽 CS!!难怪
第一题
#include<iostream.h>
#include<string.h>
void main( ){
char *a[5]={"student","worker","cadre","soldier","peasant"};//字符指针数组
char *p1,*p2;
p1=p2=a[0];
for (int i=0; i<5;i++){
if(strcmp(a[i],p1)>0) p1=a[i]; //对字符串进行比较,下同
if(strcmp(a[i],p1)<0) p2=a[i];
}
cout<<p1<<' '<<p2<<endl;
}

第二题
考查形参和实参 参见楼上的吧

第三题
#include<iostream.h>
#include<iomanip.h>
void main( ){
int a[10]={2,4,6,8,10,12,14,16,18,20};
for(int i=0;i<10;i++){
cout<<setw(5)<<*(a+i); //setw设置输出宽度
if((i+1)%4==0) cout<<endl; //i+1原来的是i=1,应该是打错了的
}
}
输出结果
2 4 6 8
10 12 14 16
18 20Press any key to continue

如果你一直在线 我一题一题写下来 随时更新

程序有很多语法错误
#include<iostream.h>//包含头文件<