Advertisement
mostlabs

14-12

May 13th, 2020
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3.  
  4.  
  5. using namespace std;
  6.  
  7.   /*Описать тип Complex - с полями вещественного типа re(действительная часть), im
  8. (мнимая часть) и функцию conjComplex(c), с параметром c типа Complex, которая
  9. вычисляет комплексно - сопряженное для c комплексное число.Аргумент с является
  10.  
  11. входным и выходным параметром.Применить функцию conjComplex для вычисления
  12.  
  13. комплексно - сопряженных чисел для пяти заданных комплексных чисел. */
  14.  
  15. struct karmasiksayi
  16. {
  17.  
  18. public:
  19.     int reel;
  20.     int sanal;
  21.  
  22.    
  23.     void print(karmasiksayi a)
  24.     {
  25.  
  26.         if (a.sanal > 0)
  27.             cout << a.reel <<  "-" << +1 * a.sanal << "i" << endl;
  28.         else if (a.sanal < 0)
  29.             cout <<a.reel << "+" << -1 * a.sanal << "i" << endl;
  30.         else
  31.             cout << a.reel << endl;
  32.  
  33.     }
  34.  
  35.  
  36. };
  37.  
  38. int main()
  39. {
  40.     karmasiksayi s1 , a;
  41.     cout << "reel:";
  42.     cin >> s1.reel;
  43.     cout << "sanal:";
  44.     cin >> s1.sanal;
  45.  
  46.     a.print(s1);
  47.    
  48. }
  49.  
  50.  
  51. /*Даны названия 26 городов и стран, в которых они находятся.Среди них есть города,
  52. находящиеся в Италии.Напечатать их названия.*/
  53.  
  54. /*void siralama(struct al* a);
  55. struct al
  56. {
  57.     string country;
  58.     string city;
  59.  
  60. };
  61. int main()
  62. {
  63.  
  64.     struct al a[100];
  65.  
  66.     for (int i = 0; i < 26; i++) {
  67.         cout << "country" << i + 1 << ":";
  68.         cin >> a[i].country;
  69.         cout << "city" << i + 1 << ":";
  70.         cin >> a[i].city;
  71.     }
  72.  
  73.     siralama(&a[0]);
  74.     return 0;
  75. }
  76. void siralama(struct al* a) {
  77.  
  78.  
  79.  
  80.     for (int i = 0; i < 26; i++) {
  81.  
  82.         if ((*(a + i)).country == "italy") {
  83.  
  84.             cout << "italy-city:" << (*(a + i)).city << endl;
  85.         }
  86.  
  87.  
  88.     }
  89.  
  90. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement