Guest User

Untitled

a guest
Feb 22nd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cmath>
  4. #include <cstdlib>
  5. #define PI 3.14159265
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. /*
  12. 5. Opracować program zamiany temperatury wyrażonej w stopniach Celsjusza na stopnie Fahrenheita i odwrotnie.
  13.  
  14.  
  15. TC = 5/9 ( TF - 32)
  16. TF = 9/5 TC + 32
  17.  
  18. Program powinien pytać o kierunek konwersji, wczytywać temperaturę TC lub TF
  19. i wyprowadzać wartość przeliczoną wraz z jednostką.
  20.  
  21.  
  22. */
  23.  
  24. double b,c=0;
  25. int a;
  26. cout<<"Przeliczanie temperatury:"<<endl<<"1 - Celcusz -> Faranhajt"<<endl<<"2 - Faranhajt -> Celcusz "<<endl; //c = (b+32); c = 2 * (b-32);
  27. cin>>a;
  28. cout<<"podaj temperature"<<endl;
  29. cin>>b;
  30.  
  31. switch(a)
  32. {
  33. case 1:
  34. c= 9*(b+32)/5;
  35. break;
  36.  
  37. case 2:
  38. {
  39.  
  40. c= 5*(b-32)/9;
  41.  
  42. break;
  43.  
  44. }
  45.  
  46.  
  47. default:
  48. //jakiś kod
  49. break;
  50. }
  51.  
  52.  
  53. cout<<"wynik to: "<< c;
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment