如题所述
//#include "stdafx.h"//If the vc++6.0, with this line.
#include <iostream.h>
#include <iomanip.h>
class Time{
public:
Time(int hour,int minu,int seco){
h=hour,m=minu,s=seco;
}
void myshow(void){
cout << setw(2) << setfill('0') << h << ':';
cout << setw(2) << setfill('0') << m << ':';
cout << setw(2) << setfill('0') << s << endl;
}
private:
int h,m,s;
};
int main(int argc,char *argv[]){
int h,m,s;
cout << "Input hours, minutes & seconds:\n";
cin >> h >> m >> s;
Time t(h,m,s);
t.myshow();
return 0;
}追问
#include <iostream>
using namespace std;
#define pai 3.14
class CYLINDER{
public:
CYLINDER(double radius,double high){
h=high,r=radius;
}
double getvolume(void){
return pai*r*r*h;
}
private:
int h,r;
};
int main(int argc,char *argv[]){
int h,r;
cout << "Please enter the radius and high:\n";
cin >> r >> h;
CYLINDER t(r,h);
cout << t.getvolume() << endl;
return 0;
}追问
#include <iostream.h>
#include <iomanip.h>
class Time{
public:
Time(int hour,int minu,int seco){
h=hour,m=minu,s=seco;
}
void myshow(void){
cout << setw(2) << setfill('0') << h << ':';
cout << setw(2) << setfill('0') << m << ':';
cout << setw(2) << setfill('0') << s << endl;
}
private:
int h,m,s;
};
int main(int argc,char *argv[]){
int h,m,s;
cout << "Input hours, minutes & seconds:\n";
cin >> h >> m >> s;
Time t(h,m,s);
t.myshow();
return 0;
}追问
谢谢~
可以再问你一道题吗?求圆柱体体积的~
追答说吧……
追问求解答
你好,做出来了吗?
追答刚才不在。这种题你照猫画虎就可以了……
//#include "stdafx.h"//If the vc++6.0, with this line.#include <iostream>
using namespace std;
#define pai 3.14
class CYLINDER{
public:
CYLINDER(double radius,double high){
h=high,r=radius;
}
double getvolume(void){
return pai*r*r*h;
}
private:
int h,r;
};
int main(int argc,char *argv[]){
int h,r;
cout << "Please enter the radius and high:\n";
cin >> r >> h;
CYLINDER t(r,h);
cout << t.getvolume() << endl;
return 0;
}追问
好的,谢谢
温馨提示:答案为网友推荐,仅供参考