Hàm lấy thời gian hiện tại của computer

#include<iostream> using namespace std; #include<ctime> int main() {int ns,namhientai; cout<<"Moi ban nhap nam sinh cua minh";cin>>ns; time_t t=time(0);// Reset lại thời gian bằng 0 struct tm *POs=localtime(&t); // Trong Struct tm có các class như thời gian , ngày , tháng năm ...v. namhientai=POs->tm_year+1900;// dòng này tức là lấy năm trước năm 1900 nên ta phải cộng thên 1900 nó mới bằng thời gian đầu int tuoi=namhientai-ns; cout<<"Ban "<<tuoi<<"Tuoi"; system("pause"); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.