You can use recursion to implement this:
inline int my_print(int i) {
(i -1) && my_print(i-1); std::cout<<i << " "; return 1;
}
Anding of (i-1) makes sure the recursion stops when i is 1.
Now my_print(1000) will print 1 through 1000
You can use recursion to implement this:
inline int my_print(int i) {
(i -1) && my_print(i-1); std::cout<<i << " "; return 1;
}
Anding of (i-1) makes sure the recursion stops when i is 1.
Now my_print(1000) will print 1 through 1000
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.