Write a program that reads two numbers a and b, and prints all numbers between a and b.
Input: Input consists of two natural numbers a and b.
Output: Print a line with a, a+1,…, b−1, b. Separate the numbers with commas.
Input: Input consists of two natural numbers a and b.
Output: Print a line with a, a+1,…, b−1, b. Separate the numbers with commas.
#include <iostream> using namespace std; int main () { int x, y; cin >> x >> y; bool primera=true; for (int i =x; i<=y; ++i) { if (primera) primera=false; else cout << ','; cout << i; } cout << endl; }
No comments:
Post a Comment