用C++设计一个Clock时钟类程序
要求:1.能够人工及自动设置时间,并能显示人工设置时间及返回系统当前时间。2.程序结构采用多文档结构,即类的定义与声明分开。希望能讲清楚。谢谢。...
要求: 1.能够人工及自动设置时间,并能显示人工设置时间及返回系统当前时间。
2.程序结构采用多文档结构,即类的定义与声明分开。
希望能讲清楚。谢谢。 展开
2.程序结构采用多文档结构,即类的定义与声明分开。
希望能讲清楚。谢谢。 展开
2个回答
2015-07-30
展开全部
#include ?iostream.h?
#include ?string.h?
#include ?stdlib.h?
struct movies_t {
char title [50];
int year;
}mine, yours;
void printmovie (movies_t movie);
int main () {
char buffer [50];
strcpy (mine.title, "2001 A Space Odyssey");
mine.year = 1968;
cout << "Enter title: ";
cin.getline (yours.title,50);
cout << "Enter year: ";
cin.getline (buffer,50);
yours.year = atoi (buffer);
cout << "My favourite movie is:\n ";
printmovie (mine);
cout << "And yours:\n";
printmovie (yours);
return 0;
}
#include ?string.h?
#include ?stdlib.h?
struct movies_t {
char title [50];
int year;
}mine, yours;
void printmovie (movies_t movie);
int main () {
char buffer [50];
strcpy (mine.title, "2001 A Space Odyssey");
mine.year = 1968;
cout << "Enter title: ";
cin.getline (yours.title,50);
cout << "Enter year: ";
cin.getline (buffer,50);
yours.year = atoi (buffer);
cout << "My favourite movie is:\n ";
printmovie (mine);
cout << "And yours:\n";
printmovie (yours);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询