oriolmarti97

[X18325] Suma de valors dins d'un interval

Apr 30th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int i,r;
  7.     cin >>i>>r;
  8.     int n, dins=0, fora=0;
  9.     while (cin >>n) {
  10.         if (n<=r and n>=i) dins+=n;
  11.         else ++fora;
  12.     }
  13.     cout <<"Sum Inside: "<<dins<<endl;
  14.     cout <<"Num Outside: "<<fora<<endl;
  15. }
  16.  
  17. //By Patata
Advertisement
Add Comment
Please, Sign In to add comment