valenki13

Lesson3

Jun 17th, 2022
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void calc2nums() {
  5.     int val1 = 0;
  6.     int val2 = 0;
  7.     cout << "input two numbers" << endl;
  8.     cin >> val1 >> val2;
  9.     cout << val1 << " + " << val2;
  10.     cout << " = " << val1 + val2 << endl;
  11.     cout << val1 << " * " << val2;
  12.     cout << " = " << val1 * val2 << endl;
  13.     cout << "average(" << val1;
  14.     cout << ", " << val2 << ")";
  15.     cout << " = " << (float)(val1 + val2) / 2 << endl;
  16. }
  17.  
  18. void convertChars() {
  19.     char ch = 'a';
  20.     cout << ch << '\t' << (int)ch << endl;
  21.     unsigned int val = 123;
  22.     cout << val << '\t' << (char)val << endl;
  23.     cout << R"(\t)" << '\t' << (int)'\t' << endl;
  24.     cout << (unsigned char)(-10) << " " << (char)-10 << endl;
  25.     cout << (unsigned int)(-10) << " " << (int)-10 << endl;
  26. }
  27.  
  28. void calcPriceLabtop() {
  29.     setlocale(LC_ALL, "Russian");
  30.     cout << " Покупка ноутбука. " << endl;
  31.     float price;        // цена
  32.     unsigned int number;// количество
  33.     int sale;           // скидка
  34.     cout << "Введите цену ноутбука: "; cin >> price;
  35.     cout << "Введите количество ноутбуков: "; cin >> number;
  36.     cout << "Ведите величину скидки: "; cin >> sale;
  37.     float procent = (1 - sale / 100.0);
  38.     cout << "ИТОГО: " << number * price * procent << endl;
  39. }
  40.  
  41. void getChetNum() {
  42.     int val;
  43.     cout << "Введите целое число: "; cin >> val;
  44.     if ((val % 2) == 0)
  45.         cout << "Число " << val << " четное." << endl;
  46.     else
  47.         cout << "Число " << val << " нечетное." << endl;
  48. }
  49.  
  50. void showMin() {
  51.     int val1, val2;
  52.     cout << "Введите два числа:" << endl;
  53.     cin >> val1;
  54.     //cout << "\b\b\b\b";
  55.     cin >> val2;
  56.     //cout << "\b\b\b\b";
  57.     if (val1 < val2)
  58.         cout << val1;
  59.     else
  60.         cout << val2;
  61. }
  62.  
  63. void main() {
  64.     //calcPriceLabtop();
  65.     setlocale(LC_ALL, "Russian");
  66.     //getChetNum();
  67.     //showMin();
  68.     cout << "Hello world\b!" << endl;
  69.    
  70.  
  71.  
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment