如何计算一个人的年龄
How to calculate the age of a person?
例如,我需要计算从1996-11-03 (yy/mm/dd)到现在的时间。我需要做的MC visual c++在windows窗体应用程序。用户将输入年,月,日在3个不同的文本框'。什么好主意吗?
可能会对你有所帮助....
#include<iostream>
using namespace std;
int main()
{
system("TITLE how old are you?");
system("color f3");
int yearnow,yearthen,monthnow,monththen,age1,age2;
cout<<"tttEnter the current year and month nttt(eg. 1997, enter, 7, enter):n ";
cin>>yearnow;
cin>>monthnow;
cout<<"Enter your birthyear and month: n";
cin>>yearthen;
cin>>monththen;
if(monththen >12 || monththen<1)
return 1;
if(monththen > monthnow){
age1=yearnow-yearthen-1;
age2=(12-monththen) + monthnow;
}else{
age1=yearnow-yearthen;
age2=12-monththen;
}
cout<<"nntttYou are "<<age1<<" year and "<<age2<<" moth old";
system("pause>>void");
}
相关文章:
- 以小于一毫秒的精度计算时间的功能
- 一个人如何将QT(C )UI分为多个小部件子类,并使其显示与同一类中的所有窗口
- 一个人如何从代表函数的字符串中执行运行时执行C 代码
- C++ 编写一个程序,提示用户以数字形式输入一个人的出生日期(投掷/接球)
- 给定一个整数数组和一个数k,计算长度为k的每个子数组的最大值
- 使用一个人的补码加密文件
- 一个人可以使用clang ast使用名称打印功能指针的质量
- C 类是其他类的成员,一个人如何定义这个
- 一个人应该在堆栈上分配的最大数量
- 另一个人不了解main.cpp,program_name.cpp和program_name的联系。
- 我怎样才能写出一个快速函数来计算一个数的除数
- 一个人是如何实时制作东西的
- 在计算了一帧的SIFT或ORB之后,如何实时跟踪视频中的对象
- 使用boost::chrono,如何从单独的年、月、日、小时、分钟、秒计算自epoch UTC以来的毫秒
- 从日期开始计算一年中的某一天
- 一种使用STL计算std::string向量中字符数的方法
- 我如何将一年中的某一天(1-365)转换为其等效日期(即2013年1月5日)C++
- c++获取用户选择的日期与实际日期之间的年份(计算日、月、年)
- 用月来计算生命的年数
- 如何计算一个人的年龄