[c/c++]在使用循环去查询消息等操作时加入Sleep()

/ 5,220评论 / 20369阅读 / 0点赞

加入比较短时间的Sleep()一般对时效性影响不大,但能极大地降低CPU占用。

#include<conio.h>
#include<iostream>
#include<windows.h>
using namespace std;

int main()
{
	cout << "<< 按任意键继续... ";
	for (int i = 0; _kbhit() == 0;)	//等待按键
	{
		switch (i++)	//选择打印最后的一个字符,使之有动画效果
		{
		case 0:cout << "\b/"; break;
		case 1:cout << "\b-"; break;
		case 2:cout << "\b\\"; break;
		case 3:
		{
			cout << "\b|";
			i = 0;
		}break;
		}
		//Sleep(100);    //暂停100毫秒(1秒 = 1000毫秒)
	}
}
  1. Derekjup说道:

    buy amoxicillin online no prescription: com pharm – buy amoxicillin 250mg

  2. StevenWearo说道:

    where can you buy amoxicillin over the counter: com pharm – amoxicillin price without insurance

  3. Brandenven说道:

    cheap amoxicillin 500mg: buy amoxil online – medicine amoxicillin 500

  4. Derekjup说道:

    buy priligy: cheap priligy – priligy max pharm

  5. porn说道:

    I quite like looking through an article that can make people think. Also, many thanks for allowing me to comment.

  6. StevenWearo说道:

    buy prednisone canadian pharmacy: prednisone ray pharm – can you buy prednisone without a prescription

  7. StevenWearo说道:

    priligy max pharm: max pharm – priligy max pharm

  8. Brandenven说道:

    order amoxicillin 500mg: Com Pharm – over the counter amoxicillin

  9. StevenWearo说道:

    priligy max pharm: priligy – buy dapoxetine online

  10. StevenWearo说道:

    dapoxetine online: max pharm – dapoxetine price

  11. Derekjup说道:

    canada pharmacy prednisone: cheap prednisone – buy prednisone without a prescription best price

  12. Brandenven说道:

    amoxicillin 500 mg: amoxil – where can you get amoxicillin

  13. Brandenven说道:

    where buy cheap clomid pill: clomid rex pharm – how to buy clomid without dr prescription

  14. StevenWearo说道:

    amoxicillin 500 mg: buy amoxil online – amoxicillin 500 tablet

  15. Derekjup说道:

    generic amoxicillin 500mg: Amoxicillin Com Pharm – over the counter amoxicillin

  16. Brandenven说道:

    Priligy tablets: buy dapoxetine online – priligy max pharm

  17. Brandenven说道:

    amoxicillin azithromycin: Amoxicillin buy online – amoxicillin discount coupon

  18. Derekjup说道:

    how much is prednisone 10 mg: order Prednisone – order prednisone online no prescription

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注