Don't know where im doin the problem.

Hey guys.

I'm technically done with this code but there is a error in the answers.
5 9 ( for () function)

5678
6789
7890
8901
9012

Getting them is easy. Add +1 every second number.
If the number is more than 10 it shoud make the number itself zero and add +1 on the zero.

 ``1234567891011121314151617181920212223242526272829303132`` ``````#include #include #include #include using namespace std; //--------------------------------------- int main () { int sk1, sk2, sk3, sk4, a, b, i; sk1 = 0; sk2 = 0; sk3 = 0; sk4 = 0; cout << " A ir B" << endl; cin >> a >> b; for ( int i = a; i <= b; i++) { if ( a == 10) a = 0; sk1 = a ; if ( sk1 == 10) sk1 = 0; sk2 = sk1 + 1; if ( sk2 == 10) sk2 = 0; sk3 = sk2 + 1; if ( sk3 == 10) sk3 = 0; sk4 = sk3 + 1; a = a + 1; cout << sk1 << sk2 << sk3 << sk4 << endl; } return 0; }``````

5678
6789
78910
8901
9012
Last edited on
 ``12345678910111213141516171819202122232425262728`` ``````#include using namespace std; int main () { int sk1, sk2, sk3, sk4, a, b; sk1 = 0; sk2 = 0; sk3 = 0; sk4 = 0; cout << " A ir B" << endl; cin >> a >> b; for ( int i = a; i <= b; i++) { if ( a == 10) a = 0; sk1 = a ; if ( sk1 == 10) sk1 = 0; sk2 = sk1 + 1; if ( sk2 == 10) sk2 = 0; sk3 = sk2 + 1; if ( sk3 == 10) sk3 = 0; sk4 = (sk3 + 1)%10; a = a + 1; cout << sk1 << sk2 << sk3 << sk4 << endl; } return 0; }``````

 ``` A ir B 1 20 1234 2345 3456 4567 5678 6789 7890 8901 9012 0123 1234 2345 3456 4567 5678 6789 7890 8901 9012 0123 Program ended with exit code: 0 ```

 ```A ir B 5 9 5678 6789 7890 8901 9012 Program ended with exit code: 0```
Last edited on
 ``12345678910111213141516171819`` ``````#include int main() { constexpr unsigned NoSeq {4}; unsigned a {}, b {}; std::cout << "Range a - b: "; std::cin >> a >> b; if (a > b) return (std::cout << "Invalid range\n"), 1; for (; a <= b; ++a) { for (auto i {a}; i < a + NoSeq; ++i) std::cout << i % 10; std::cout << '\n'; } }``````

 ``` Range a - b: 5 9 5678 6789 7890 8901 9012 ```

Thanks you guys a lot <3
 ``123456789101112`` ``````#include #include using namespace std; int main () { string digits = "0123456789012"; int a, b; cout << "Input a and b: "; cin >> a >> b; for ( ; a <= b; a++ ) cout << digits.substr( a % 10, 4 ) << '\n'; }``````

 ```Input a and b: 5 9 5678 6789 7890 8901 9012```
Last edited on
Topic archived. No new replies allowed.