第二章
来源:互联网 发布:源氏伤害数据 编辑:程序博客网 时间:2024/05/09 15:54
2.
#include<iostream>
using namespace std;
class Time
{
public:
void cin_Time()
{
cin>>hour>>minute>>sec;
}
void cout_Time()
{
cout<<hour<<":"<<minute<<":"<<sec;
}
private:
int hour;
int minute;
int sec;
};
int main()
{
Time t;
t.cin_Time();
t.cout_Time();
return 0;
}
3.
using namespace std;
class Time
{
public:
void cin_Time();
void cout_Time();
private:
int hour;
int minute;
int sec;
};
int main()
{
Time t;
t.cin_Time();
t.cout_Time();
return 0;
}
void Time::cin_Time()
{
cin>>hour>>minute>>sec;
}
void Time::cout_Time()
{
cout<<hour<<":"<<minute<<":"<<sec;
}
4.
//student.h
#include<string>
using namespace std;
class student
{
public:
void display();
int num;
string name;
char sex;
};
//student.cpp
#include<iostream>
#include"student.h"
void student::display()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
//main.cpp
#include <iostream>
#include"student.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
student stud;
cin>>stud.num>>stud.name>>stud.sex;
stud.display();
return 0;
}
5.
//array_max.h
#include<string>
using namespace std;
class array_max
{
public:
void set_value();
void max_value();
void show_value();
private:
int array[10];
int max;
};
//array_max.cpp
#include<iostream>
#include"array_max.h"
using namespace std;
void array_max::set_value()
{
int i;
for(i=0;i<10;i++)
{
cin>>array[i];
}
}
void array_max::max_value()
{
int i;
max=array[0];
for(i=1;i<10;i++)
{
if(array[i]>max)max=array[i];
}
}
void array_max::show_value()
{
cout<<"max="<<max;
}
#include<iostream>
#include"array_max.h"
using namespace std;
int main()
{
array_max arrmax;
arrmax.set_value();
arrmax.max_value();
arrmax.show_value();
return 0;
}
6..
#include <iostream>
#include"v_sum.h"
using namespace std;
int main()
{
v_sum v1,v2,v3;
int v_sum1,v_sum2,v_sum3;
v1.get();
v_sum1=v1.getv();
v2.get();
v_sum2=v2.getv();
v3.get();
v_sum3=v3.getv();
cout<<"v1="<<v_sum1<<endl<<"v2="<<v_sum2<<endl<<"v3="<<v_sum3;
return 0;
}
//v_sum.h
using namespace std;
class v_sum
{
public:
void get();
int getv();
private:
int lengh;
int width;
int height;
};
//v_sum.cpp
#include<iostream>
#include"v_sum.h"
using namespace std;
void v_sum::get()
{
cout<<"分别输入长宽高"<<endl;
cin>>lengh>>width>>height;
cout<<"lengh="<<lengh<<endl<<"width="<<width<<endl<<"height="<<height<<endl;
}
int v_sum::getv()
{
int v=0;
v=lengh*width*height;
return v;
}
- 第二章 --- 第二节
- 【第二章 第二节】
- 第二章第二题
- 第二章第二题
- 第二章第二题
- 第二章
- 第二章
- 第二章
- 第二章
- 第二章
- 第二章
- 第二章
- 《第二章》
- 第二章
- 第二章
- 第二章
- 第二章
- 第二章
- javascript动态增删行的实现
- 解决CCScale9Sprite类无法使用的问题
- Android 编程下 Touch 事件的分发和消费机制
- 黑马程序员_缓冲区
- 操作系统 - 地址重定位
- 第二章
- python中比较几个常用的名词解释
- Android SDK中Intel X86 HAXM的安装
- Linux常用命令大全
- ld.linux.so源代码分析--RTLD_START
- hiho_41周_骨牌覆盖一_找规律+矩阵快速幂
- ubuntu下 双显卡Optimus笔记本 CUDA配置教程(成功解决黑屏问题)
- SQLServer2005+附加数据库时出错提示操作系统错误5(拒绝访问)错误5120的解决办法
- quick2.2.6 使用控制台新建项目