C++ 如何使程序在循环中发出哔哔声?
我需要一些代码方面的帮助,我希望它能够使用警报功能使计算机发出“哔哔”声,即:\a但我不知道如何实现它,以便用户可以选择在使用switch语句时发出多少次哔哔声,所有帮助都将得到真诚的感谢C++ 如何使程序在循环中发出哔哔声?,c++,C++,我需要一些代码方面的帮助,我希望它能够使用警报功能使计算机发出“哔哔”声,即:\a但我不知道如何实现它,以便用户可以选择在使用switch语句时发出多少次哔哔声,所有帮助都将得到真诚的感谢 #include <iostream> using namespace std; int main() { int x; int y; cout << "Do you want to make your computer beep" << en
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Do you want to make your computer beep" << endl;
cin >> x;
if (x == 'y' || x == 'Y')
{
cout << "How many beeps do you want" << endl;
switch (y)
{
// This is the part i'm stuck on!!!
}
}
cin.ignore();
cin.get();
return 0;
}
#包括
使用名称空间std;
int main()
{
int x;
int-y;
cout x;
如果(x='y'| | x='y')
{
cout您可能不应该使用开关来执行此操作,否则您必须为他们可能选择的每个数字编写一个案例。此处应使用for循环:
int n;
cout << "How many beeps? " << endl;
cin >> n;
for (int i = 0; i < n; i++) {
cout << "\a";
}
intn;
cout n;
对于(int i=0;i cout您可能不应该使用开关来执行此操作,否则您必须为他们可能选择的每个数字编写一个案例。此处应使用for循环:
int n;
cout << "How many beeps? " << endl;
cin >> n;
for (int i = 0; i < n; i++) {
cout << "\a";
}
intn;
cout n;
对于(int i=0;i cout使用switch你永远也写不完你的程序,有无限的可能性!(事实上有–2147483648到2147483647)使用for循环代替:
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Do you want to make your computer beep" << endl;
cin >> x;
if (x == 'y' || x == 'Y')
{
cout << "How many beeps do you want" << endl;
for(int i = 0; i < y; i++)
{
cout << "\a";
}
}
cin.ignore();
cin.get();
return 0;
}
#包括
使用名称空间std;
int main()
{
int x;
int-y;
cout x;
如果(x='y'| | x='y')
{
cout使用switch你永远也写不完你的程序,有无限的可能性!(事实上有–2147483648到2147483647)使用for循环代替:
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Do you want to make your computer beep" << endl;
cin >> x;
if (x == 'y' || x == 'Y')
{
cout << "How many beeps do you want" << endl;
for(int i = 0; i < y; i++)
{
cout << "\a";
}
}
cin.ignore();
cin.get();
return 0;
}
#包括
使用名称空间std;
int main()
{
int x;
int-y;
cout x;
如果(x='y'| | x='y')
{
很抱歉,你听说过“循环”吗?是的,但是当(x!=y)或者在lil中进行解释时,我该如何实现它呢more@FuzionSki:你在使用什么平台?有一声蜂鸣()在Windows中,你可以使用。你是C++新手还是编程新手?如果只是C++,你能提供一些伪代码吗?@福泽恩:我只是希望你永远不会在野外发布它,我讨厌嘟嘟!抱歉,你听说过“循环”吗?是的,但是我如何实现它呢?(x!= y)或是在lil里的什么东西more@FuzionSki你使用什么平台?在Windows中有一个Bebe()函数,它可以被使用。你是C++新手还是编程新手?如果只是C++,你能提供一些伪代码吗?@福西恩:我只是希望你永远不会在野外释放它,我讨厌哔哔声!