/*
先看别人的,在做自己的;
#include<iostream>
using namespace std;
/*
char *input(char*p)
{
cout<<"input your name:";
cin>>p;
return p;
}
int main()
{
char name[20];
cout<<input(name)<<endl;
}
void show(int &m)
{
++m;}
int main()
{
int a=10;
show(a);
cout<<"a="<<a<<endl;
}*/
/*
#include<iostream>
using namespace std;
#include<cstdlib>
#include<ctime>
struct Time{
int hour;
int min;
int sec;
void set(int h,int m, int s);
void tick();
void show();
void run();
};
int main()
{
Time t;
t.set(10,45,50);
t.run();
}
void Time::set(int h,int m,int s)
{
hour=h;
min=m;
sec=s;
}
void Time::tick()
{
long t=time(NULL);
while(time(NULL)==t);
if( ++sec>=60){
sec=0;
if(++min>=60){
min=0;
if(++hour>=24){
hour=0;
}
}
}
}
void Time::show()
{
if(hour<10)
cout<<0;
cout<<hour<<":";
if(min<10)
cout<<0;
cout<<min<<":";
if(sec<10)
cout<<0;
cout<<sec<<'\r';
}
void Time::run()
{
for(;;){
tick();
show();
}
}*/
//一百秒的秒表
/*
#include<iostream>
using namespace std;
#include<ctime>
class accout{
int sec;
public:
void set(int s);
void tick();
void show();
void run();
};
int main()
{
accout t;
t.set(10);
t.run();
}
void accout::set(int s)
{
sec=s;
}
void accout::tick()
{
long t=time(NULL);
while(t==time(NULL));
sec--;
}
e
void accout::show()
{
cout<<sec<<'\r';
if(sec==0) cout<<"\a\a\a\a\a"<<" 时间到!!!!"<<endl;
}
void accout::run()
{
while(sec>=0){
tick();
show();
}
}
*/
/*
#include<iostream>
using namespace std;
#include<ctime>
class Clock{
private:
int h;
int m;
int s;
public:
void set(int hour,int minute,int second);
void tick();
void show();
void run();
};
int main()
{
Clock t;
t.set(0,1,23);
t.run();
}
void Clock::set(int hour,int minute,int second)
{
h=hour;
m=minute;
s=second;
}
void Clock::tick()
{
time_t t=time(NULL);
while(t==time(NULL));
if(--s<0){
s=59;
if(--m<0){
m=59;
--h;
}
}
}
void Clock::show()
{
if(h<10) cout<<0;
cout<<h<<":";
if(m<10) cout<<0;
cout<<m<<":";
if(s<10) cout<<0;
cout<<s<<"\r";
}
void Clock::run()
{
while(h!=0||m!=0||s!=0)
{
tick();
show();
}
cout<<"\a\a\a\a\a"<<" 时间到!!!"<<endl;
}
*/
/*
//倒计时时间从键盘输入,每一秒发出滴答声。
#include<iostream>
using namespace std;
#include<ctime>
class Clock{
int h;
int m;
int s;
public:
void set(int hour,int minute,int second);
void tick();
void show();
void run();
};
int main()
{
int hour,second,minute;
Clock t;
t.set( hour,minute,second);
t.run();
}
void Clock::set(int hour,int minute,int second)
{
cout<<"请输入计时时间:";
cin>>hour>>minute>>second;
h=hour;
m=minute;
s=second;
}
void Clock::tick()
{
time_t t=time(NULL);
while(t==time(NULL));
if(--s<0){
s=59;
if(--m<0){
m=59;
--h;
}
}
cout<<"\a";
}
void Clock::show()
{
if(h<10) cout<<0;
cout<<h<<":";
if(m<10) cout<<0;
cout<<m<<":";
if(s<10) cout<<0;
cout<<s<<"\r";
}
void Clock::run()
{
while(h!=0||m!=0||s!=0)
{
tick();
show();
}
cout<<"\a\a\a 时间到!!!"<<endl;
}
*/
/*
#include<iostream>
using namespace std;
#include<ctime>
class Clock{
int h;
int m;
int s;
public:
Clock(int hour,int minute,int second);
void tick();
void show();
void run();
};
int main()
{
Clock t(0,2,0);
t.run();
}
Clock::Clock(int hour,int minute,int second)
{
cout<<"请输入计时时间:";
cin>>hour>>minute>>second;
h=hour;
m=minute;
s=second;
}
void Clock::tick()
{
time_t t=time(NULL);
while(t==time(NULL));
if(--s<0){
s=59;
if(--m<0){
m=59;
--h;
}
}
cout<<"\a";
}
void Clock::show()
{
if(h<10) cout<<0;
cout<<h<<":";
if(m<10) cout<<0;
cout<<m<<":";
if(s<10) cout<<0;
cout<<s<<"\r";
}
void Clock::run()
{
while(h!=0||m!=0||s!=0)
{
tick();
show();
}
cout<<"\a\a\a 时间到!!!"<<endl;
}
*/
/*