daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.     int main() {
  4.         int x, k, n, v[50], i, contor, j, Suma = 0, numar;
  5.         printf(" Scrie n =  ");
  6.         scanf("%i", &n);
  7.         printf("Scrie fiecare element al vectorului: ");
  8.         for(i = 0; i < n; i++){
  9.             scanf("%i", &v[i]);
  10.         }
  11.         printf(" x =  ");
  12.         scanf("%i", &x);
  13.         printf(" y =  ");
  14.         scanf("%i", &k);
  15.         for(i = 0; i < n;i++){
  16.             if(v[i] == x){
  17.                 Suma = 0;
  18.                 for(j = 1; j <= k; j++){
  19.                     scanf("%i", &numar);
  20.                     Suma += numar;
  21.                 }
  22.             v[i] = Suma;
  23.             }
  24.         }
  25.  
  26.         for(i = 0; i < n; i++){
  27.             printf("%i ", v[i]);
  28.         }
  29.  
  30.  
  31.     return 0;
  32.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top