hpnq

лаба номер 1

Sep 13th, 2023
743
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.07 KB | None | 1 0
  1. #include <bits/stdc++.h>
  2. #include <windows.h>
  3. #define ll long long
  4. #define all(x) x.begin(), x.end()
  5. #define sz(x) x.size()
  6. #define loop(i, q, x) for(int i = q; i < x; i++)
  7. //#define loop(i,j, x) for(int i = j; i < x; i++)
  8.  
  9. #define DEBUG 1
  10. using namespace std;
  11. struct p{
  12.     double x, y;
  13. };
  14. void b1(){
  15.     string s;
  16.     cin >> s;
  17.     string s1 = s.substr(4, 3) + '.' +s.substr(0, 3);
  18.     cout << s1;
  19. }
  20.  
  21. void b3(){
  22.     p p1, p2;
  23.     cin >> p1.x >> p1.y >> p2.x >> p2.y;
  24.     double k = (p2.y-p1.y)/(p2.x-p1.x);
  25.     double b = (p2.x*p1.y-p2.y*p1.x)/(p2.x-p1.x);
  26.     cout << format("y = {}x + {}", k, b) << endl;
  27. //    cout << p2.y-p1.y << " " << p2.x-p1.x;
  28. }
  29. void b4(){
  30.     string s;
  31.     cin >> s;
  32.     bool t = false;
  33.     int c = 0;
  34.     loop(i, 0, sz(s)){
  35.         if(c < 4 && t){
  36.             cout << s[i] << " ";
  37.         }
  38.         if(s[i] == ','){
  39.             t = true;
  40.         }
  41.         c+=t;
  42.  
  43.     }
  44. }
  45. void b5(){
  46.     double h, m;
  47.     cin >> h >> m;
  48.     double degperh = 360/12;
  49.     cout << "Hours" << setw(15) << "Minutes" << setw(15) << "angle(deg)\n";
  50.     cout << h << setw(15) << m << setw(15) << degperh*(h + m/60);
  51. }
  52. void b6(){
  53.     ll x;
  54.     cin >> x;
  55.     vector<ll> dp(x+1,10000000);
  56.     dp[0] = 0;
  57.     vector<ll> a = {10, 5, 2, 1};
  58.     loop(i, 1, x+1){
  59.         for(auto q : a){
  60.             if(i-q >= 0){
  61.                 dp[i] = min(dp[i], dp[i-q]+1);
  62.             }
  63.         }
  64.     }
  65.     cout << dp[x];
  66.  
  67. }
  68. void b7(){
  69.     double x, y, z;
  70.     cin >> x >> y >> z;
  71.     double cosx = acos(x/(sqrt(x*x + y*y + z*z)));
  72.     double cosy = acos(y/(sqrt(x*x + y*y + z*z)));
  73.     double cosz = acos(z/(sqrt(x*x + y*y + z*z)));
  74.  
  75. }
  76. void b8(){
  77.     ll h, m, s;
  78.     cin >> h >> m >> s;
  79.     cout << h*60*60 + m * 60 + s;
  80. }
  81. void b9(){ // ?????
  82.     ll s;
  83.     cin >> s;
  84.     ll h = s/60/60;
  85.     s-= h*60*60;
  86.     ll min = s/60;
  87.     s-= min*60;
  88.  
  89.     ll sec = s;
  90.  
  91.     cout << "Часы" << setw(15) << "Минуты" << setw(15) << "Секунды" << endl;
  92.  
  93.     cout << h << setw(15) << min << setw(15) << sec << endl;
  94.  
  95. }
  96. void b10(){
  97.     double a, b, c;
  98.     cin >> a >> b >> c;
  99. //    double metres =
  100.             // 1 дюйм = 2.54 cm
  101.             // 12 дюймов = фут
  102.             // 3 фута = 1 ярд
  103.     double acm = a*3*12*2.54, adec = acm*10, amet = adec*10; // ярды
  104.     double bcm = b*12*2.54, bdec = bcm*10, bmet = bdec*10; // футы
  105.     double ccm = c*2.54, cdec = ccm*10, cmet = cdec*10; // дюймы
  106.     double cm = 100;
  107.     double metres = cm/100;
  108.     double yard = cm/2.54/12/3, foot = cm/2.54/12, inch =cm/2.54;
  109. //    cout << foot;
  110. //    cout << 2.54*;
  111.     cout << "Yard " << setw(15) << "Foot " << setw(15) << "Inch\n";
  112.     cout << setprecision(5) <<yard << setw(15) << foot << setw(15) << inch;
  113. }
  114.  
  115.  
  116. int main() {
  117. //    SetConsoleOutputCP(CP_UTF8);
  118. //    if (setlocale(LC_ALL, "") == NULL) {
  119. //        puts("Unable to set locale");
  120. //    }
  121.     SetConsoleCP(1251);
  122.     SetConsoleOutputCP(1251);
  123.  
  124. //    cout << "абс\n";
  125. #ifdef DEBUG
  126.     freopen("text.txt", "r", stdin);
  127. #endif
  128.     b9();
  129.  
  130.     return 0;
  131. }
  132.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment