/*2*/ //#include //using namespace std; //int main() //{ // double x; // double sum = 0; // cout << "Enter reals:\n"; // do { // cin >> x; // if (x > 0.) sum += x; // } while (x != 0.); // cout << "sum = " << sum << endl; // system("pause"); return 0; //} /*3*/ //#include //using namespace std; // //void getNumberInformation(int n); //void isNum(int n, int nf); //void Digits(int n); //int getMin(int a, int b); //int getMax(int a, int b); // //int main() { // int n, nFind; // cout << "enter number : "; cin >> n; // cout << "\nenter the number you want to find : "; cin >> nFind; // getNumberInformation(n); // isNum(n, nFind); // Digits(n); // cout << endl; // system("pause"); // return 0; //} // //void getNumberInformation(int n) { // int sum = 0, k = 0, firstDigit, lastDigit, resOfFindNum = 0; // lastDigit = n % 10; // while (n != 0) { // if (n < 10) firstDigit = n; // sum += n % 10; // n /= 10; // k++; // } // cout << "\nquantity = " << k << "\nsum = " << sum << "\nfirst digit : " << firstDigit << "\nlast digit : " << lastDigit; //} // //void isNum(int n, int nf) { // int resOfFindNum = 0; // while (n) { // resOfFindNum = n % 10 == nf ? resOfFindNum + 1 : resOfFindNum; // n /= 10; // } // if (resOfFindNum != 0) cout << "\nnumber " << nf << " found, " << " number of digits in number : " << resOfFindNum; // else cout << "\nnumber " << nf << " not found\n"; //} // //void Digits(int n) //{ // int largest = 0; // int smallest = 9; // // while (n) { // int r = n % 10; // // Find the largest digit // largest = getMax(r, largest); // // Find the smallest digit // smallest = getMin(r, smallest); // n = n / 10; // } // cout << "\nlargest = " << largest << "\nsmallest = " << smallest; //} // //int getMin(int a, int b) { // int t; // a < b ? t = a : t = b; // return t; //} // //int getMax(int a, int b) { // int t; // a > b ? t = a : t = b; // return t; //} /*4*/ //#include //using namespace std; // //int factorial(int n) { // if (n < 0) // return 0; // if (n == 0) // return 1; // else // return n * factorial(n - 1); //} // //int main() { // int a; // cout << "a : "; cin >> a; // int n = 1; // // while (factorial(n) <= a) { // if (factorial((n + 1)) > a) { // break; // } else n++; // } // cout << "n = " << n; // system("pause"); // return 0; //} /*5*/ //#include //using namespace std; // //double getLogNM(int n, int m) { // return (log(m) / log(n)); //} // //int main() { // int n, m; // do { // cout << "n and m : "; cin >> n >> m; // if (m <= 0 || n <= 0) cout << "Error: you enter wrong number!\n"; // else { // int res = getLogNM(n, m); // cout << "\nres : " << res << endl; // } // } // while (m <= 0 || n <= 0); // system("pause"); // return 0; //} /*6*/ //#include //#include //using namespace std; // //void setSequence(vector &s); //string hasError(vector s); //void getSequence(vector s); // //int main() //{ // do { // vector sequence; // string errorMsg; // cout << "enter the sequence (you can complete the sequence by pressing 'enter' and entering any item except 't' and 'a') :\n"; // setSequence(sequence); // errorMsg = hasError(sequence); // if (errorMsg == "false") { // cout << "\nsequence : "; getSequence(sequence); cout << "\n\n"; // } else cout << errorMsg << endl; // } while (true); // system("pause"); return 0; //} // //string hasError(vector s) { // int quantityT = 0, quantityA = 0; // for (int i = 0; i < s.size(); i++) { // (s[i] == 't') ? quantityT++ : quantityA++; // } // if (quantityT != quantityA) return "error : the quantity of 't' must be equal to quantity of 'a'!"; // else if (quantityT + quantityA > 20) return "error : the quantity 'ta' should be less than 10!"; // else return "false"; //} // //void setSequence(vector &s) { // char elOfTA; // while (cin >> elOfTA) { // if (elOfTA == 't' || elOfTA == 'a') s.push_back(elOfTA); // else break; // } //} // //void getSequence(vector s) { // for (int i = 0; i < s.size(); i++) // cout << s[i]; //} /*7*/ //#include //using namespace std; //int main() { // double op1, op2, res; // char sign; // int state = 0; // bool isContinue = true; // char yesOrNo, y = 'y', n = 'n'; // do { // cout << "Enter double, sign (+,-,*,/)," << // " and double\n"; // cin >> op1 >> sign >> op2; // switch (sign) { // case '+': res = op1 + op2; break; // case '-': res = op1 - op2; break; // case '*': res = op1 * op2; break; // case '/': if (op2 != 0) // res = op1 / op2; // else state = 1; // break; // default: state = 2; // } // switch (state) { // case 0: cout << "===\n" << res << endl; break; // case 1: cout << "Division by zero\n"; break; // default: cout << "Wrong operator\n"; // } // do { // cout << "Do you want to continue (enter y - yes, or n - not) : "; cin >> yesOrNo; // if (yesOrNo != y && yesOrNo != n) cout << "You enter incorrect simbol!\nPlease, enter again...\n"; // if (yesOrNo == y) isContinue = true; // else isContinue = false; // } while (yesOrNo != y && yesOrNo != n); // } while (isContinue == true); //} /*8*/ //#include //#include //#include //using namespace std; // //void input(); //void tab(double a, double b, int h); //void isError(double a, double b, int h); // //int main() //{ // input(); // // return 0; //} // //void input() { // double a, b; // int h; // cout << "Enter a, b ([a; b] is the tabbed segment) and a positive integer h is the tabulation step : "; cin >> a >> b >> h; // tab(a, b, h); //} // //void tab(double a, double b, int h) { // isError(a, b, h); // int lenght = b - a; // for (int i = 0; i <= lenght; i++) { // if ((a + (i * h)) <= b) { // cout << setw(b - (a / h)) << a + (i * h) << " | " << sin(a + (i * h)) << endl; // b--; // } // // } //} // /* // cout << setw((a + b) / h) << a + (i * h) << " " < b) { // cout << "Error: 'b' must be larger then 'a'\n"; // input(); // } // if (h <= 0) { // cout << "Error: 'h' must be larger then 0\n"; // input(); // } //} /*9*/ //#include //#include //#include //using namespace std; // //void input(); //void tab(double a, double b, int h); //void isError(double a, double b, int h); //void printVoidChar(int t); // //int main() //{ // input(); // // return 0; //} // //void input() { // double a, b; // int h; // cout << "Enter a, b ([a; b] is the tabbed segment) and a positive integer h is the tabulation step : "; cin >> a >> b >> h; // tab(a, b, h); //} // //void printVoidChar(int t) { // for (int i = 0; i < t; i++) cout << " "; //} // //void tab(double a, double b, int h) { // isError(a, b, h); // int x; // int lenght = b - a; // for (int i = 0; i < lenght; i++) { // x = a + (i * h); // printVoidChar(h); // cout << sin(x); // printVoidChar(h); // cout << cos(x) << endl; // } //} // //void isError(double a, double b, int h) { // if (a > b) { // cout << "Error: 'b' must be larger then 'a'\n"; // input(); // } // if (h <= 0) { // cout << "Error: 'h' must be larger then 0\n"; // input(); // } //} /*10*/ //#include //#include //#include //using namespace std; // //void input(); //void tab(double a, double b, int h); //void isError(double a, double b, int h); //void printVoidChar(int t); // //int main() //{ // input(); // // return 0; //} // //void input() { // double a, b; // int h; // cout << "Enter a, b ([a; b] is the tabbed segment) and a positive integer h is the tabulation step : "; cin >> a >> b >> h; // tab(a, b, h); //} // //void tab(double a, double b, int h) { // isError(a, b, h); // bool isZero = true; // int m; // int zero; // cout << "How many rows to print : "; cin >> m; cout << endl; // do { // for (int i = 0; i < m; i++) { // printVoidChar(h); // cout << sin(a + (i * h)) << endl; // } // cout << "Do you want to continue (0 - no) : "; cin >> zero; cout << endl; // zero == 0 ? isZero = true : isZero = false; // } while (isZero == false); //} // //void printVoidChar(int t) { // for (int i = 0; i < t; i++) cout << " "; //} // //void isError(double a, double b, int h) { // if (a > b) { // cout << "Error: 'b' must be larger then 'a'\n"; // input(); // } // if (h <= 0) { // cout << "Error: 'h' must be larger then 0\n"; // input(); // } //} /*11*/ //#include //using namespace std; // //int doubleFactorial(int n) { // int f = 1; // if (n % 2 == 0) { // for (int i = 2; i <= n; i += 2) f *= i; // } else { // for (int i = 1; i <= n; i += 2) f *= i; // } // return f; //} // //int main() { // int n; // cout << "n : "; cin >> n; // int res = doubleFactorial(n); // cout << "\nres = " << res << endl; // system("pause"); // return 0; //} /*12*/ //#include //#include //using namespace std; // //void arcthSinX(int m, double a, double h) { // double x; // for (int i = 0; i <= m; i++) { // x = a + i * h; // cout << "arctg(sin(" << x << ")) = " << atan(sin(x)) << endl; // } // //} // //int main() { // int m; // double a, h; // cout << "m : "; cin >> m; // cout << "\na : "; cin >> a; // cout << "\nh : "; cin >> h; // arcthSinX(m, a, h); // cout << endl; // system("pause"); // return 0; //} /*13*/ //#include //using namespace std; // //int fibo(int n) { // int f2 = 0, f1 = 1, f; // if (n < 0) return -1; // if (n == 0) return f2; // if (n == 1) return f1; // for (int i = 1; i < n; i++) { // f = f1 + f2; // f1 = f; f2 = f1; // /*f= f1 + f2; // f2 = f1; f1 = f; */ // } // return f; //} // // int main() { // do { // int n, res; // cout << "n : "; cin >> n; // res = fibo(n); // cout << "\nres : " << res << endl; // } while (true); // system("pause"); // return 0; //} /*14*/ //#include //using namespace std; // //int recA(int n) { // int a0 = 0, a1 = 3, a2 = -2, a; // if (n < 0) return -1; // if (n == 0) return a0; // if (n == 1) return a1; // if (n == 2) return a2; // for (int i = 1; i < n; i++) { // a = 3 * a1 - a0; // a0 = a1; a1 = a; // } // return a; //} // //int main() { // do { // int n, res; // cout << "n : "; cin >> n; // res = recA(n); // cout << "\nres : " << res << endl; // } while (true); // system("pause"); // return 0; //} /*16*/ //#include //using namespace std; // //long long fibo(long long n) { // long long f2 = 0, f1 = 1, f; // if (n < 0)return -1; // if (n == 0) return f2; // if (n == 1) return f1; // int i; // for (i = 1; i < n; i++) f = f1 + f2; f2 = f1; f1 = f; // return f; //} // //int main() { // // long long resOfFibo; // long long i = 0; // while (i < INT_MAX) { // resOfFibo = fibo(i); // if (resOfFibo < INT_MAX) { // cout << "\ni = " << i ; // i++; // continue; // } else { // i--; // resOfFibo = fibo(i); // cout << "\nmax of int = " << INT_MAX << "\nresult of fibo() = " << resOfFibo << endl; // break; // } // break; // } // /* // while (resOfFibo < INT_MAX) { // resOfFibo = fibo(i); // if (resOfFibo > INT_MAX) { // i--; // resOfFibo = fibo(i); // cout << "max of int = " << INT_MAX << "\ni = " << i << "\n result of fibo() = " << resOfFibo; // break; // } // }*/ // system("pause"); // return 0; //} /*17*/ //#include //using namespace std; // //double sqrtToNDegree(double n) { // double x = sqrt(3 * n); // for (int i = n; i > 1; i--) // x = sqrt(3 * (i - 1) + x); // return x; //} // //int main() //{ // double n, sum; // do { // cout << "\nn = "; cin >> n; // sum = sqrtToNDegree(n); // cout << "sum = " << sum << endl; // } while (true); // system("pause"); return 0; //}