Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #pragma once
  2. #include<iostream>
  3. #include<cmath>
  4. #include<string>
  5. #include<map>
  6.  
  7. using std::cout;
  8. using std::cin;
  9.  
  10. struct Complex {
  11.     double cz_rzeczywista;
  12.     double cz_urojona;
  13. };
  14.  
  15. void printComplex(Complex instance) {
  16.     cout << instance.cz_rzeczywista;
  17.     if(instance.cz_urojona != 0)
  18.         cout << std::showpos << instance.cz_urojona << "i";
  19.     cout << std::noshowpos;
  20. }
  21.  
  22. Complex createComplex(double cz_rzeczywista, double cz_urojona) {
  23.     Complex ret{cz_rzeczywista, cz_urojona};
  24.     return ret;
  25. }
  26.  
  27. Complex addComplex(Complex num_1, Complex num_2) {
  28.     Complex ret {
  29.         num_1.cz_rzeczywista + num_2.cz_rzeczywista,
  30.         num_1.cz_urojona + num_2.cz_urojona
  31.     };
  32.     return ret;
  33. }
  34.  
  35. bool compareComplex(Complex num_1, Complex num_2) {
  36.     double num_1_mod = sqrt(num_1.cz_rzeczywista - num_1.cz_urojona);
  37.     double num_2_mod = sqrt(num_2.cz_rzeczywista - num_2.cz_urojona);
  38.     if (num_1_mod == num_2_mod)
  39.         return true;
  40.     else
  41.         return false;
  42. }
  43.  
  44. enum Type { zimowa, letnia };
  45. // Etykietki dla enum Type
  46. std::string TypeLabels[] = {
  47.     "zimowa",
  48.     "letnia"
  49. };
  50.  
  51. struct Wheel {
  52.     Type type;
  53. };
  54. struct Car {
  55.     Wheel tires[4];
  56.     Car() {
  57.         for (int i = 0; i < 4; i++)
  58.             this->tires[i].type = Type::zimowa;
  59.     };
  60. };
  61.  
  62. void printCarTires(Car car) {
  63.     cout << "[*] Samochód:\n";
  64.     for (int i = 0; i < 4; i++)
  65.         cout << "Opona: " << i+1 << " : " << TypeLabels[car.tires[i].type] << "\n";
  66. }
  67.  
  68. bool checkCar(Car car) {
  69.     bool ret = true;
  70.     for (int i = 1; i < 4; i++)
  71.         if (car.tires[i].type != car.tires[i - 1].type)
  72.             ret = false;
  73.     return ret;
  74. }
  75.  
  76. void setType(Car &car, Type type) {
  77.     for (int i = 0; i < 4; i++)
  78.         car.tires[i].type = type;
  79. }
  80.  
  81. struct Date {
  82.     int year;
  83.     int month;
  84.     int day;
  85. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement