Advertisement
Avdluna

uidhashdhhhh

Aug 29th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int n,x,y,soma=0,i,j;
  7.  
  8.         scanf("%d", &n);
  9.  
  10.             for(i = 0 ; i < n ; i++){
  11.                 scanf("%d %d", &x, &y);
  12.  
  13.                 if(x<y){
  14.  
  15.                 for(j=x ; j < y ; j++){
  16.  
  17.                     if(j%2 !=0){
  18.  
  19.                     soma +=j;
  20.  
  21.                     }
  22.  
  23.                     }
  24.  
  25.                 }
  26.  
  27.                 else{
  28.  
  29.                     for(j = y ; j < x ; j++){
  30.  
  31.                         if(j%2 != 0){
  32.  
  33.                             soma +=j;
  34.  
  35.                         }
  36.                     }
  37.  
  38.                 }
  39.                    printf("%d\n", soma);
  40.  
  41.                     soma = 0;
  42.             }
  43.  
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement