Advertisement
delta_zero

Untitled

Dec 23rd, 2023 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6. struct Atom
  7. {
  8.     std::string name;
  9.     double mass;
  10.     double APF;
  11.     double r;
  12. };
  13.  
  14. Atom elemList[] =
  15. {
  16.     { "Po",   208.998, 0.52360, 1.68 },
  17.     { "Li",     6.941, 0.68017, 1.52 },
  18.     { "Na", 22.989770, 0.68017, 1.86 },
  19.     { "Cr",   51.9961, 0.68017, 1.28 },
  20.     { "Mn", 54.938049, 0.68017, 1.27 },
  21.     { "Fe",    55.845, 0.68017, 1.26 },
  22.     { "Mo",     95.94, 0.68017, 1.39 },
  23.     { "Ta",  180.9749, 0.68017, 1.46 },
  24.     { "Al", 26.981538, 0.74048, 1.43 },
  25.     { "Ca",    40.078, 0.74048, 1.97 },
  26.     { "Ni",   58.6934, 0.74048, 1.24 },
  27.     { "Cu",    63.546, 0.74048, 1.28 },
  28.     { "Ge",     72.64, 0.74048, 1.22 },
  29.     { "Ag",  107.8682, 0.74048, 1.44 },
  30.     { "Pt",   195.078, 0.74048, 1.39 },
  31.     { "Au", 196.96655, 0.74048, 1.44 },
  32.     { "Pb",     207.2, 0.74048, 1.75 }
  33. };
  34.  
  35. template <int N> double pow(double a) { return a * pow<N - 1>(a); }
  36.  
  37. template <> double pow<0>(double a) { return 1; }
  38.  
  39. int main()
  40. {
  41.  
  42.     int n;
  43.     std::cin >> n;
  44.     for (int i = 0; i < n; ++i)
  45.     {
  46.         std::string in;
  47.         std::cin >> in;
  48.         for(const auto& e : elemList)
  49.         {
  50.             if(e.name == in)
  51.             {
  52.                 double V = 4.0 * M_PI * pow<3>(e.r) / 3.0;
  53.                 std::cout << std::fixed << std::setprecision(2) << 10.0 * e.mass * e.APF / 6.022 / V << std::endl;
  54.                 break;
  55.             }
  56.         }
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement