Advertisement
EmanuelF

;-;

Mar 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.    
  7.     int pontos, fases, quantidade_de_pontos;
  8.     int i, soma, dif, resultado;
  9.    
  10.     cin >> pontos >> fases;
  11.    
  12.     soma=0;
  13.    
  14.     for(i=1;i<=fases;i++){
  15.        
  16.         cin >> quantidade_de_pontos;
  17.          
  18.         soma += quantidade_de_pontos;
  19.         resultado = soma + pontos;
  20.        
  21.         if(resultado>100){
  22.            
  23.             dif = 100 - resultado;
  24.            
  25.             if(dif<0)
  26.                 dif=-dif;
  27.            
  28.             if(quantidade_de_pontos<0)
  29.            
  30.                 resultado = resultado - dif + quantidade_de_pontos;
  31.            
  32.             else
  33.                 resultado = resultado - dif;
  34.            
  35.         }
  36.        
  37.         if(resultado<0)
  38.            resultado=0;
  39.        
  40.     }
  41.    
  42.     cout << resultado << endl;
  43.    
  44.    
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement