Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- #include <sstream>
- #include <string>
- using namespace std;
- int main() {
- char separator = ' ';
- string line;
- getline(cin,line);
- int k = 0, a = 0;
- string tsep = " ";
- while (line[a]!='\0') {
- if (line[a] != ' ') {
- k++;
- }
- a++;
- }
- int n = 0;
- string::size_type pos = 0;
- while ((pos = line.find(tsep, pos)) != string::npos) {
- n++;
- pos += tsep.size();
- }
- n++;
- int * numbers = new int[n];
- stringstream line_streamed(line);
- string number;
- int i = 0;
- while (getline(line_streamed, number, separator)) {
- numbers[i] = atoi(number.c_str());
- i++;
- }
- int *b = new int[n];
- b[0] = numbers[0];
- cout << b[0] << endl;
- for (int i = 1; i < n; i++) {
- b[i] = numbers[i] - b[i - 1];
- cout << b[i] << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement