daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Dec 11th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using std::cin;
  3. using std::cout;
  4. int main() {
  5.     int n,k;
  6.     cin >> n >> k;
  7.     int* mas = new int[n+2];
  8.     int* buff = new int[n];
  9.     for(int i=1;i<n+1;++i){
  10.         cin >> mas[i];
  11.     }
  12.     mas[0]=mas[1];mas[n+1]=mas[n];
  13.     for(int i=0; i<k;++i){
  14.         for(int j=0; j<n;++j){
  15.             buff[j] = (mas[j]+mas[j+1]+mas[j+2])/3;
  16.         }
  17.         for(int j=0; j<n;++j){
  18.             mas[j+1]=buff[j];
  19.         }
  20.         mas[0]=mas[1];mas[n+1]=mas[n];
  21.     }
  22.     for(int j=0; j<n;++j) {
  23.         cout << mas[j+1] << " ";
  24.     }
  25.     return 0;
  26. }
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