Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. int predkosc[3];
  9. int czas[3];
  10. int droga[3];
  11.  
  12. for(int i=0; i<3; i++)
  13. {
  14. cout<<"Podaj predkosc "<<i<<" pojazdu: ";
  15. cin>>predkosc[i];
  16. cout<<"Podaj czas "<<i<<" pojazdu: ";
  17. cin>>czas[i];
  18. }
  19.  
  20. for(int i=0; i<3; i++)
  21. {
  22. droga[i]=predkosc[i]*czas[i];
  23. }
  24.  
  25. int mind=droga[0];
  26. int flag=0;
  27.  
  28. for(int i=0; i<3; i++)
  29. {
  30. if (mind>droga[i])
  31. {
  32. mind=droga[i];
  33. flag=i;
  34. }
  35. }
  36.  
  37. cout<<"Najkrotsza droga przejechal pojazd nr "<<flag<<" z predkoscia: "<<mind;
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement