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

/ 5,219评论 / 20356阅读 / 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. StevenWearo说道:

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

  2. Brandenven说道:

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

  3. Derekjup说道:

    buy priligy: cheap priligy – priligy max pharm

  4. porn说道:

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

  5. StevenWearo说道:

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

  6. StevenWearo说道:

    priligy max pharm: max pharm – priligy max pharm

  7. Brandenven说道:

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

  8. StevenWearo说道:

    priligy max pharm: priligy – buy dapoxetine online

  9. StevenWearo说道:

    dapoxetine online: max pharm – dapoxetine price

  10. Derekjup说道:

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

  11. Brandenven说道:

    amoxicillin 500 mg: amoxil – where can you get amoxicillin

  12. Brandenven说道:

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

  13. StevenWearo说道:

    amoxicillin 500 mg: buy amoxil online – amoxicillin 500 tablet

  14. Derekjup说道:

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

  15. Brandenven说道:

    Priligy tablets: buy dapoxetine online – priligy max pharm

  16. Brandenven说道:

    amoxicillin azithromycin: Amoxicillin buy online – amoxicillin discount coupon

  17. Derekjup说道:

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

发表回复

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