如何使switch-case语句不区分大小写?说我做了这样的事情:
#include <stdio.h>
char choice;
int main ()
{
char choice;
printf("Will you choose A,B, or C?\n>");
scanf(" %c", &choice);
switch(choice)
{
case 'A':
printf("The First Letter of the Alphabet");
break;
case 'B':
printf("The Second Letter of the Alphabet");
break;
case 'C':
printf("The Third Letter of the Alphabet");
break;
}
}
Run Code Online (Sandbox Code Playgroud)
它只会回应大写字母.如何让它回复小写字母?
我正在使用ncurses进行打字游戏.字母从屏幕上掉下来,您必须在它们到达底部之前键入它们.除了一个问题外,它工作得很好.清除窗口(使用clear())会使输出闪烁.我在循环的开头放了clear(),在最后放了wrefresh().它不应该等待直到wrefresh显示任何东西,因此不闪烁?
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <curses.h>
#include <fstream>
using namespace std;
int main(){
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
nodelay(stdscr, TRUE);
srand(time(NULL));
//input character integer (ASCII)
int ch = 1;
//int to store the last time the character positions were updated
int lastupdate = time(NULL);
//x,y,char arrays for falling characters and initialization
int chars[10], x[10], y[10];
for(int i = 0; i < 10; i++){
chars[i] = rand()%25 + 97;
x[i] = rand()%30;
y[i] = 0;
//y[i] …Run Code Online (Sandbox Code Playgroud)