Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void nums() {
- int a = 1;
- int ch1, ch2, ch3; // для суммы
- int n; // это для кол.-ва цифр
- ch1 = a % 10;
- a /= 10;
- ch2 = a % 10;
- a /= 10;
- ch3 = a % 10;
- if (ch3)
- n = 3;
- else if (ch2)
- n = 2;
- else if (ch1)
- n = 1;
- else
- n = 0;
- cout << "n: " << n << endl;
- cout << "s: " << ch1 + ch2 + ch3 << endl;
- }
- void nums2() {
- int a = 768;
- int s =0; // для суммы
- int n = 0; // это для кол.-ва цифр
- if (a)
- n += 1;
- s += a % 10;
- a /= 10;
- if (a)
- n += 1; // n = n + 1
- s += a % 10; // s = s + (a % 10)
- a /= 10; // a = a / 10
- if (a)
- n += 1;
- s += a % 10;
- cout << "n: " << n << endl;
- cout << "s: " << s << endl;
- }
- void test_incr() {
- int x = 0;
- int y = x++;
- cout << y << x << endl;
- x++;
- cout << x << endl;
- cout << x++ << endl;
- cout << x << endl;
- int p = 0;
- int q = ++p;
- cout << q << p << endl;
- ++p;
- cout << p << endl;
- cout << ++p << endl;
- cout << p << endl;
- cout << ++++++++p << endl;
- }
- void test_while1() {
- int iter = 0;
- while (iter < 10) {
- ++iter;
- cout << iter << ' ';
- //cout << "Hello" << endl;
- }
- }
- void test_sum() {
- // 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
- // 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 = ???
- int sum = 0, k = 1, num = 10;
- int prod = 1;
- while (k <= num) {
- sum += k;
- prod *= k;
- ++k;
- }
- int n = 0;
- while (n < num-1/*10*/) {
- n++;
- cout << n;
- cout << " + ";
- /*if (n < 10)
- cout << " + ";
- else
- cout << " = ";*/
- }
- cout << ++n << " = ";
- cout << sum << endl;
- //cout << "prod: " << prod << endl;
- }
- void test_line() {
- int num = 8;
- bool is_horizontal = 0;
- int k = 0;
- if(is_horizontal)
- while (k < num) {
- cout << "#";
- k++;
- }
- else
- while (k < num) {
- cout << "#" << endl;
- k++;
- }
- }
- void table_fun() {
- double x = 0;
- const double pi = 3.1415926;
- while (x < 360) {
- cout << x << "\t" << sin(x * pi / 180.0) << endl;
- x += 5;
- }
- }
- int main() {
- //test_line();
- table_fun();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement