Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Split a number and store it in vector

#include <bits/stdc++.h>
using namespace std;
main() {
	int n = 1213456;
	vector<int> v;
	for(; n; n/=10)
  		v.push_back( n%10 );
	reverse(v.begin(), v.end());
	for (auto &i : v) cout<<i;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: ifstream 
Cpp :: int to string C++ Using stringstream class 
Cpp :: C++ to specify size and value 
Cpp :: __builtin_popcount long long 
Cpp :: DSA 2. Complexity Analysis Google drive Educative excellent courses!!!! [Educative.io] Competitive Programming in C++ The Keys to Success 
Cpp :: c++ class methods 
Cpp :: shift element to end of vector c++ 
Cpp :: vector iterator in c++ 
Cpp :: how to insert in a queue c++ 
Cpp :: Basic Makefile C++ 
Cpp :: how to take input in 2d vector in c++ 
Cpp :: C++ Vector Operation Change Elements 
Cpp :: << in C++ 
Cpp :: C++ Class Template Declaration 
Cpp :: floyd algorithm 
Cpp :: Decision Making in C / C++ (if , if..else, Nested if, if-else-if ) 
Cpp :: book allocation problem in c++ 
Cpp :: how atan work c++ 
Cpp :: store arbitrarly large vector of doubles c++ 
Cpp :: object inside class c++ 
Cpp :: warning: base will be initialized after 
Cpp :: copy file to vector c++ 
Cpp :: identity 
Cpp :: convert c++ to mips 
Cpp :: why wont a function stop C++ 
Cpp :: digits in c++ 
Cpp :: cpp stacks 
Cpp :: what does npl mean? 
Cpp :: dfs in tree using adjacency list 
Cpp :: C++ Array With Empty Members 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =