Advertisement
JewishCat

Андрей

May 17th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <sstream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main() {
  11.     char separator = ' ';
  12.     string line;
  13.     getline(cin,line);
  14.     int k = 0, a = 0;
  15.     string tsep = " ";
  16.     while (line[a]!='\0') {
  17.         if (line[a] != ' ') {
  18.             k++;
  19.         }
  20.         a++;
  21.     }
  22.     int n = 0;
  23.     string::size_type pos = 0;
  24.     while ((pos = line.find(tsep, pos)) != string::npos) {
  25.         n++;
  26.         pos += tsep.size();
  27.     }
  28.     n++;
  29.     int * numbers = new int[n];
  30.     stringstream line_streamed(line);
  31.     string number;
  32.     int i = 0;
  33.     while (getline(line_streamed, number, separator)) {
  34.         numbers[i] = atoi(number.c_str());
  35.         i++;
  36.     }
  37.     int *b = new int[n];
  38.     b[0] = numbers[0];
  39.     cout << b[0] << endl;
  40.     for (int i = 1; i < n; i++) {
  41.         b[i] = numbers[i] - b[i - 1];
  42.         cout << b[i] << endl;
  43.     }
  44.     system("pause");
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement