而大写和小写字母输入的功能

问题描述 投票:-2回答:1
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <time.h>
#include <unistd.h>
#include <dos.h>
#include <windows.h>
#include <chrono>
#include <thread>

using namespace std;
using namespace std::this_thread; // sleep_for, sleep_until
using namespace std::chrono; // nanoseconds, system_clock, seconds

int main()
{
    string word = "A";
    do
    {
    system("CLS");
    system("COLOR 3");
    cout<<"\nH";
    usleep(50000);
    cout<<"I ";
    usleep(50000);
    cout<<"T";
    usleep(50000);
    cout<<"H";
    usleep(50000);
    cout<<"E";
    usleep(50000);
    cout<<"R";
    usleep(50000);
    cout<<"E "<<endl<<endl;
    sleep_for(seconds(1));
    cout<<"H";
    usleep(50000);
    cout<<"O";
    usleep(50000);
    cout<<"W ";
    usleep(50000);
    cout<<"A";
    usleep(50000);
    cout<<"R";
    usleep(50000);
    cout<<"E ";
    usleep(50000);
    cout<<"Y";
    usleep(50000);
    cout<<"O";
    usleep(50000);
    cout<<"U? "<<endl<<endl;
    usleep(50000);
    sleep_for(seconds(1));
    cout<<"H";
    usleep(50000);
    cout<<"O";
    usleep(50000);
    cout<<"P";
    usleep(50000);
    cout<<"E ";
    usleep(50000);
    cout<<"Y";
    usleep(50000);
    cout<<"O";
    usleep(50000);
    cout<<"U";
    usleep(50000);
    cout<<"'R";
    usleep(50000);
    cout<<"E ";
    usleep(50000);
    cout<<"D";
    usleep(50000);
    cout<<"O";
    usleep(50000);
    cout<<"I";
    usleep(50000);
    cout<<"N";
    usleep(50000);
    cout<<"G ";
    usleep(50000);
    cout<<"G";
    usleep(50000);
    cout<<"R";
    usleep(50000);
    cout<<"E";
    usleep(50000);
    cout<<"A";
    usleep(50000);
    cout<<"T"<<endl<<endl;
    usleep(50000);
    cout<<"A.Im doing great :)       B.Im sad :/"<<endl;

    cin>>word;
}
    while(word!="A"||word!="a"); //I want to let input be upper/lower case
    cout<<"this means its A and going for next command"<<endl;
    return 0;
}

你好,所以基本上我是大学新生,学习计算机科学课程,我正在努力学习自己(比其他人领先一步)

在这个程序中我的目标是制作一个响应式机器:带有2个或更多答案选项的问题,如果答案不在上下文中,则使用系统(“CLS”)然后重复问题(循环)。装饰:用于颜色的“系统颜色”,用于字母动画的“usleep”,用于字线之间的间隙的“sleep_for”

1.我如何修复while命令,它无法检测到我是否同时将两个条件都设置为“while(word!=”A“|| word!=”a“);”如果有一种更简单的方法来逐字逐句,请告诉我。

c++ while-loop conditional-statements
1个回答
0
投票

错误> while(word!="A"|| word!="a");

修复> while(word!="A"&& word!="a");

感谢drescherjm

© www.soinside.com 2019 - 2024. All rights reserved.