我在 Visual Studio 2019 上用 C 制作了一个控制台游戏。我制作了一个打印变量的代码。
它仅在 value 大于 10 时才起作用。
如果变量的值小于 10,它会打印 10 而不是 1, 2 而不是 20 ... 9 而不是 90。
我不知道如何解决这个问题。
这是我的代码
#include<stdio.h>
#include<windows.h>
int a =20;
void gotoxy(int x, int y) { //cursor goes to x, y
COORD CursorPosition = { x,y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), CursorPosition);
}
void HideCursor() {
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(consoleHandle, &info);
}
void count() {
char c = _getch();
switch (c) …Run Code Online (Sandbox Code Playgroud)