Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- void twice() {
- int a = 0, b = 0;
- int a_max = 5, b_max = 4;
- while (a <= a_max) {
- b = 0;
- while (b <= b_max) {
- cout << "(" << a
- << ", " << b
- << ")" << endl;
- b++;
- }
- a++;
- }
- }
- void test_ternarny() {
- double a = 8, b = 7;
- // Case 1
- if (a > b)
- cout << a / b << endl;
- else
- cout << b / a << endl;
- // Case 2.1
- cout << ((a > b) ? a / b : b / a) << endl;
- // Case 2.2
- (a > b) ? cout << (a / b) << endl :
- cout << (b / a) << endl;
- }
- void test_mod() {
- int a = 7;
- int b = 3;
- cout << b << "*" << a / b
- << " + " << a % b
- << " = " << a << endl;
- }
- void test_sqrt() {
- int d = 0;
- double val;
- while (d <= 100) {
- val = sqrt(d);
- if (int(val) == val)
- cout << d << " -- "
- << val << endl;
- d++;
- }
- cout << sqrt(37) << endl;
- }
- void test_dowhile() {
- int x = 0;
- do {
- x += 1;
- cout << x << endl;
- } while (x <= 5);
- }
- bool is_simple(int n) {
- bool is_simple = true;
- int k = 2;
- while (k < n) {
- if (n % k == 0) return false;
- k++;
- }
- return true;
- }
- void simple_num2() {
- int n = 1;
- int summ = 0;
- do {
- if (is_simple(n)) {
- cout << n << " ";
- summ += n;
- }
- n++;
- } while (summ < 1000);
- cout << endl;
- cout << summ << endl;
- }
- void test_clock() {
- int num_bam = 0;
- for (int hour = 1; hour <= 12; hour++) {
- num_bam += hour;
- for (int bam = 0; bam < hour; bam++) {
- system("cls");
- cout <<"Load: " << bam;
- Sleep(500);
- }
- //cout << endl;
- }
- cout << num_bam << endl;
- }
- void simple_num() {
- int n = 1, k = 0, summ = 0;
- bool is_simple;
- while (n <= 1000) {
- k = 2;
- is_simple = true;
- while (k < n) {
- if (n % k == 0) {
- is_simple = false;
- break;
- }
- k++;
- }
- if (is_simple) {
- cout << n << " ";
- summ += n;
- }
- n++;
- }
- cout << endl;
- }
- int main() {
- //twice();
- //test_ternarny();
- //test_dowhile();
- //simple_num2();
- test_clock();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment