Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- double seg[n],distancia[n],h,m,s,velocidade[n];
- for(int i=0; i<n; i++){
- cin>>h>>m>>s;
- cin>>distancia[i];
- seg[i]=h*3600 + m*60 + s;
- }
- for(int i=0; i<n-1; i++){
- velocidade[i]=(abs((distancia[i+1])-(distancia[i])))/(seg[i+1] - seg[i]);
- }
- double menor=velocidade[0],maior=velocidade[0];
- for(int i=0; i<n-1; i++){
- if(velocidade[i]<menor){
- menor=velocidade[i];
- }
- if(velocidade[i]>maior){
- maior=velocidade[i];
- }
- }
- for(int i=0; i<n-1; i++){
- cout<<fixed<<setprecision(2)<<velocidade[i]<<endl;
- }
- cout<<"Velocidade Maxima = "<<maior<<endl;
- cout<<"Velocidade Minima = "<<menor<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement