Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bài 1
- #include<iostream>
- using namespace std;
- int main()
- {
- cout << "Hello world" << endl;
- system("pause");
- return 0;
- }
- // bài 2
- #include<iostream>
- using namespace std;
- int main()
- {
- int x;
- int y;
- cout << "nhap x y";
- cin >> x >> y;
- if (x == 0)
- {
- if (y == 0)
- {
- cout << "tong 2 so " << x + y << endl;
- cout << "hieu so " << x - y << endl;
- cout << "tich 2 so " << x*y << endl;
- cout << "khong co thuong " << endl;
- }
- else
- {
- cout << "tong 2 so " << x + y << endl;
- cout << "hieu x-y " << x - y << endl;
- cout << "hieu so y-x " << y - x << endl;
- cout << "tich 2 so " << x*y << endl;
- cout << "thuong so x/y " << x / y << endl;
- }
- }
- else
- {
- if (y == 0)
- {
- cout << "tong 2 so " << x + y << endl;
- cout << "hieu so x-y " << x - y << endl;
- cout << "hieu so y-x " << y - x << endl;
- cout << "tich 2 so " << x*y << endl;
- cout << "thuong so y/x " << y / x << endl;
- }
- else
- {
- cout << "tong 2 so " << x + y << endl;
- cout << "hieu so x-y " << x - y << endl;
- cout << "hieu so y-x " << y - x << endl;
- cout << "tich 2 so " << x*y << endl;
- cout << "thuong so x/y " << x / y << endl;
- cout << "thuong so y/x " << y / x << endl;
- }
- }
- system("pause");
- return 0;
- }
- // bài 3
- #include<iostream>
- using namespace std;
- int main()
- {
- double dSothuc;
- cout << "nhap so thuc ";
- cin >> dSothuc ;
- cout << static_cast<long long>(dSothuc) << endl;
- system("pause");
- return 0;
- }
- // bài 4
- #include<iostream>
- using namespace std;
- int main()
- {
- char a;
- cout << "nhap ki tu bat ky";
- cin >> a;
- cout << static_cast<int>(a) << endl;
- system("pause");
- return 0;
- }
- // bài 5
- #include<iostream>
- #include<ctime>
- #pragma warning(disable:4996)
- using namespace std;
- int main()
- {
- int nYear;
- cout << "nhap nam sinh";
- cin >> nYear;
- time_t baygio = time(0);
- tm*ltm = localtime(&baygio);
- cout << "so tuoi" << 1900 + ltm->tm_year - nYear << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement