Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- /*
- int main1() {
- return 0;
- }
- int main2() {
- return 0;
- }
- */
- using namespace std;
- void task1() {
- cout << "BuBuBu" << endl;
- }
- void test_menu() {
- char ch;
- do {
- task1();
- cout << "Enter \'n\' for exit\n";
- cin >> ch;
- } while (ch != 'n');
- }
- void split_number() {
- // fedcba
- int n = 754328;
- /*
- int a = n % 10; // 8
- int b = (n / 10) % 10; // 2
- int c = (n / 10 / 10) % 10; // 3
- int d = (n / 10 / 10 / 10) % 10; // 4
- int e = (n / 10 / 10 / 10 / 10) % 10; // 5
- int f = (n / 10 / 10 / 10 / 10 / 10) % 10; // 7
- */
- /*
- // Считаем сумму цифр числа
- int sum = 0;
- do {
- sum += n % 10;
- n = n / 10;
- } while (n > 0);
- cout << sum << endl;
- */
- int sum1 = 0;
- int sum2 = 0;
- int iter = 0;
- do {
- iter++;
- /*
- Заменим этот код на тернарный опереатор
- if (iter < 4) {
- sum1 += n % 10;
- }
- else {
- sum2 += n % 10;
- }
- */
- (iter < 4) ? sum1 += n % 10 : sum2 += n % 10;
- n = n / 10;
- } while (n > 0);
- cout << sum1 << " " << sum2 << endl;
- }
- void lucky_ticket() {
- // 765 675 - номер билета
- int ticket_number = 1;
- int result = 0;
- do {
- int sum1 = 0;
- int sum2 = 0;
- int n = ticket_number;
- int iter = 0;
- do {
- iter++;
- (iter < 4) ? sum1 += n % 10 : sum2 += n % 10;
- n /= 10;
- } while (n > 0);
- if (sum1 == sum2) {
- //cout << ticket_number << endl;
- result++;
- }
- ticket_number++;
- } while (ticket_number <= 999999);
- cout << "TOTAL:" << result << endl;
- }
- void test_ternarny() {
- int n = 7;
- cout << (n > 5) ? "Hello": "By";
- (n > 5) ? ((cin >> n), 1) : ((cout << 55) , 1);
- int y = (n > 5) ? 3 : 5;
- if (n > 5)
- y = 3;
- else
- y = 5;
- /*
- if (n > 5)
- cin >> n;
- else
- cout << 55;
- */
- cout << endl << n << endl;
- }
- void draw_square() {
- int n = 7;
- //cin >> n;
- int k = 0;
- while (k < n * n) {
- k++;
- cout << " @";
- if (k % 7 == 0) {
- cout << endl;
- }
- }
- cout << endl;
- }
- int main() {
- setlocale(LC_ALL, "russian");
- //test_ternarny();
- //cout << 9 / 2 << endl;
- //test_menu();
- //split_number();
- //draw_square();
- //lucky_ticket();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment