#include <iostream>
using namespace std;
int main()
{
char c;
int n;
cout << " Please enter a letter of the Alphabet and a decimal number";
cin >> c >> n;
if (c == 'a'|| c== 'e'|| c== 'i'|| c== 'o'|| c== 'u'||c == 'A'|| c== 'E'|| c== 'I'|| c== 'O'|| c== 'U' )
{
cout << c << " is a vowel" << endl;
}
else
{
cout << c << " is a consonant" << endl;
}
float x;
cin >> x;
if (x<0)
cout << x << " is less than 0";
else if (x>0&&x<100)
cout << x << " is in range ";
else
cout << x << " is out of bounds";
return 0;
}
当输入A,41.5时,输出如下:
A是元音nan是越界的。
我希望代码能够找到这两个问题的答案,并告诉我它是否小于0,在范围内,或超出界限,还说,字母是一个元音或辅音,我该如何去做呢?
1条答案
按热度按时间avwztpqn1#
您的输入不正确。正确的输入示例为:
代码读取三个输入:
char c
int n
float x
请阅读:https://www.geeksforgeeks.org/cin-in-c/