Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- ifstream f;
- f.open("input.txt", ios::in);
- string s, num;
- vector<string> nums;
- while (getline(f, s)) {
- for (size_t i = 0; i < s.size(); ++i) {
- if(isdigit(s[i])) {
- num += s[i];
- } else {
- if (num != "") {
- nums.push_back(num);
- }
- num = "";
- }
- }
- if (num != "") {
- nums.push_back(num);
- }
- num = "";
- }
- f.close();
- for (string &elem : nums) {
- cout << elem << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement