Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1. Сумма цифр четырехзначного числа
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int k;
- cin >> k;
- cout << k%10 + k/10%10 + k/100%10 + k/1000%10 << endl;
- }
- //2. k-я секунда суток
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int k;
- cin >> k;
- cout << "It is " << k/3600 << " hours " << (k%3600)/60 << " minutes.";
- }
- //3. Часовая стрелка
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int d;
- cin >> d;
- int k = d * 120;
- cout <<"It is "<< k/3600 <<" hours " << (k%3600)/60 << " minutes.";
- return 0;
- }
- //4. Симметричное число
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int d;
- cin >> d;
- int k1 = d % 10;
- int k2= d/10%10;
- int k3= d/100%10;
- int k4 = d/1000%10;
- cout << (k1 == k4 && k2 == k3);
- }
- //5. Урок в неделе
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int d;
- int f;
- cin >> d >> f;
- cout << 6* (d-1) + f;
- }
- //6. Без циклов
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int k,n;
- cin >> k >> n;
- int d = (n + k - 1) /k;
- cout << d << ' ' << (n-1)%k + 1;
- }
- //7. День недели
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int m,n;
- cin >> n >> m;
- int d = m + n - 1;
- cout << (d - 1) % 7 + 1;
- }
- //8. Покупка
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a,b,n;
- cin >> a >> b >> n;
- cout << a*n + (b*n)/100 << ' ' << (b*n)%100;
- }
- //9.
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- double a;
- cin >> a;
- cout << (int)a << ' ' << (a - (int)a) * 100 ;
- }
- //10. Два момента времени
- #include <bits/stdc++.h>
- using namespace std;
- int h, m, s;
- int h1, m1, s1;
- int main(){
- cin >> h >> m >> s >> h1 >> m1 >> s1;
- cout << ((h1 - h - 1) * 3600) + ((60 - m - 1) * 60) + (60 - s) + (m1 * 60) + s1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement