第1个回答 2011-06-15
/*错误:char b[]后面少了;还有,少了b数组的长度.
还有,reverse是一库函数,得改一下名.还有,你的程序是不对.你main()函数中用到返回值,但是在reverse()函数中没有返回.我来给你写一段吧,如下:*/
#include <iostream.h>
#include <string.h>
#define max 100
char *sreverse(char *s,int sta,int end)
{
char c,e;
int n=end;
if(end>sta)
{
c=s[sta];
e=s[end];
s[sta]=e;
s[end]=c;
sta++;
end--;
sreverse(s,sta,end);
}
return s;
}
void main()
{
char a[max];
char *p;
cout<<"请输入字符串:";
cin>>a;
cout<<"逆序前为:"<<a<<endl;
p=sreverse(a,0,strlen(a)-1);
cout <<"逆序后为:"<<p<<endl;
}
第2个回答 2011-06-16
忻州师院的吧 哥救你 但是 运行不了 希望你不是 二班的
#include<iostream.h>
#include<math.h>
#define PI 3.14159;
class circle
{
double a,b,r;
public:
void fun1(double i,double j,double k)
{
a=i;
b=j;
r=k;
}
void fun2()
{cout<<"圆锥圆心坐标:"<<a<<","<<b<<endl<<"底面圆的半径:"<<r<<endl;}
void area()
{
double s;
s=PI*r*r;
cout<<"圆锥的底面积是:"<<s<<endl;
}
};
class height
{
int h;
public:
fun3(int i)
{h=i;}
fun4()
{cout<<"圆锥高为:"<<h;}
};
class c:public circle,public height
{
public:
void V()
{
int v;
v=1/3*PI*r*r*h;
cout<<"圆锥的体积为:"<<v<<endl;
}
void S()
{
c=PI*r*sqrt(h*h-r*r)+PI*r*r;
cout<<"圆锥的表面积为:"<<c<<endl;
};
void main()
{
int i,j,k
cout<<"请输入圆锥的底面圆的圆心坐标:"<<endl;
cout<<"请输入圆锥的高:"<<endl;
cin>>i>>j>>k;
c obj;
obj.fun1(i,j);
obj.fun2();
obj.fun3(k);
obj.fun4();
obj.V();
obj.S();
}