Как исправить порядок печати в C++ [закрыто]C++

Программы на C++. Форум разработчиков
Anonymous
 Как исправить порядок печати в C++ [закрыто]

Сообщение Anonymous »

Я работаю над заданием, математическая игра с обратным отсчетом. Игра работает так, как задумано, но не совсем так, как хочет автогрейдер. Числа печатаются в другом порядке, чем на автогрейдере. Пожалуйста, помогите. Я пытался это исправить, но не нашел решения.

Ввод:

Код: Выделить всё

27
1
5-1
100 * 4
7*10
400-70
Мой результат:

Код: Выделить всё

Enter random seed:
Let's play Countdown!
How many big numbers would you like (0-4)?
Your numbers are: 100 5 5 10 1 7
The target is: 330
Enter a calculation (or 0 to quit):
5 - 1 = 4
Your numbers are: 100 5 10
4 7

The target is: 330
Enter a calculation (or 0 to quit):
100 * 4 = 400
Your numbers are: 5 10
400 7

The target is: 330
Enter a calculation (or 0 to quit):
7 * 10 = 70
Your numbers are:
5
70
400

The target is: 330
Enter a calculation (or 0 to quit):
400 - 70 = 330
You win!
Ожидаемый результат:

Код: Выделить всё

Enter random seed:
Let's play Countdown!
How many big numbers would you like (0-4)?
Your numbers are: 100 5 5 10 1 7
The target is: 330
Enter a calculation (or 0 to quit):
5 - 1 = 4
Your numbers are: 100
4
5 10
7
The target is: 330
Enter a calculation (or 0 to quit):
100 * 4 = 400
Your numbers are:
400
5 10
7
The target is: 330
Enter a calculation (or 0 to quit):
7 * 10 = 70
Your numbers are:
400
70
5

The target is: 330
Enter a calculation (or 0 to quit):
400 - 70 = 330
You win!
Код:

Код: Выделить всё

 #include 
#include 
#include 
#include 
#include "mersenne-twister.h"

int chooseRandomNumber(int min, int max);
using namespace std;
int num1 , num2 , num3 , num4 , num5 , num6;

int countRemainingNumbers(){
int count = 0;
if(num1 != 0) count ++;
if(num2 != 0) count ++;
if(num3 != 0) count ++;
if(num4 != 0) count ++;
if(num5 != 0) count ++;
if(num6 != 0) count ++;
return count;
}

void printRemainingValues(int t2){
cout 

Подробнее здесь: [url]https://stackoverflow.com/questions/79035558/how-to-fix-print-order-in-c[/url]

Вернуться в «C++»