Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bai 1
- int n, a[100], dem = 0, tong = 0;
- cout << "Nhap n: "; cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Nhap a[" << i << "]: "; cin >> a[i];
- }
- for (int i = 0; i < n; i++) {
- if (a[i] % 2 == 1) dem++;
- if (a[i] >= -20 && a[i] <= 50) tong += a[i];
- }
- cout << "So luong so le: " << dem << endl;
- cout << "Tong trong khoang [-20, 50]: " << tong << endl;
- // bai 2
- string s; int dem = 0;
- cout << "Nhap s: "; getline(cin, s);
- for (int i = 0; i < s.size(); i++) {
- if (isupper(s[i])) dem++;
- s[i] = toupper(s[i]);
- }
- cout << "So ky tu in hoa: " << dem << endl;
- cout << "Xau s sau khi chuyen: " << s << endl;
Advertisement
Add Comment
Please, Sign In to add comment