Advertisement
fcamuso

C++ 20 - lezione 7

Oct 23rd, 2022
722
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <format>
  3. #include <numbers>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     cout << format("Costante di Nepero: {}\n", numbers::e);
  10.     cout << format("pi greco: {}\n", numbers::pi);
  11.     cout << format("Inverso di pi greco: {}\n", numbers::inv_pi);
  12.  
  13.     cout << format("Radice di 2: {}\n", numbers::sqrt2);
  14.     cout << format("Radice di 3: {}\n", numbers::sqrt3);
  15.  
  16.     enum class Status { On, Off, StandBy };
  17.  
  18.     using enum Status;
  19.     Status stato = Off;
  20.     stato = Status::On;
  21.  
  22.     //const int Off = -90;
  23.  
  24.     const int v[] {10, 20, 30, 40};
  25.    
  26.     for (int parziale = 0; int ele : v)
  27.     {
  28.         parziale += ele;
  29.         cout << parziale << endl;
  30.     }
  31.  
  32.     array arr{ to_array({10, 20, 30, 40}) };
  33.     arr = to_array(v);
  34.  
  35.    
  36.     struct Nemico
  37.     {
  38.         int codice;
  39.         string classe{ "npc" };
  40.         string sottoClasse{ "npc" };
  41.         int potenza{ 0 };
  42.     };
  43.  
  44.     Nemico numberOne{ .codice{666}, .potenza{9999} };
  45.    
  46.  
  47. }
  48.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement