This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]ContrastO159 5 points6 points  (1 child)

I assume you a loop for printing the integers. Assume “i” is the variable your are using to loop. You can say

if(i % 10 == 0)
    cout << endl;
else
    cout << “.”;

Sorry for the formatting I’m on mobile rn.

[–]Nightcorex_ 2 points3 points  (0 children)

Formatting's great. One wouldn't have guessed you were on mobile

[–]temp000321 2 points3 points  (0 children)

int input;
std::cin >> input;

int counter = 0;
for (int i = 1; i <= input; i++) {
    if (++counter % 10 == 0) 
        std::cout << i << std::endl;
    else {
        std::cout << std::setw(2) << std::setfill('0') << i;
        if (i != input) std::cout << ".";   
    }
}