练习2.倒计时

版权声明:此文章为作者筱睿_原创文章,转载请附上博客链接 https://blog.csdn.net/qq_43756486/article/details/86681118

倒计时

这个程序很简单,就不过多解释了,语句后面我都注释了,这里用c++实现

#include<iostream>
#include<windows.h>
using namespace std;
int main(){
	system("color 0a");        //改输出字体颜色,实际没什么用
    int a;
	cout<<"请输入你要倒计时的时间"<<endl;
	cin>>a;
	while(a>=0)
	{system("cls");             //清屏语句
	 cout<<a;
	 Sleep(1000);               //延迟1000,单位是毫秒
	 a--; 
	 } 
	
	system("pause");
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_43756486/article/details/86681118