C++中的各种“神奇”东西
2024-08-27 21:41:13
将光标放到任意的位置
void gotoxy(int x,int y)//位置函数
{
COORD pos;
pos.X=x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
实现让文字显示一段时间后消失
for(int i=;i<=;i++){
gotoxy(i,);
printf("%d ",i);
Sleep();
system("cls");//清屏
}
实现限时输入
#include <iostream>
#include <cstdio>
#include <windows.h>
#include<ctime>
#include <conio.h> using namespace std; char in() {
char a;
time_t timeBegin = time();
int n=;
while(true) { //the main loop || 主循环
if(kbhit()){ //detect the keyboard || kbhit检测键盘输,如果发现了输入
a = _getch() ;
return a;
} else if(time()-timeBegin== && n==) {
cout << "Your time have "<< <<" s"<< endl;//输出倒计时
n=;
}
else if(time()-timeBegin== && n==) {
cout << "Your time have "<<<<" s"<< endl;//输出倒计时
n=;
}
else if(time()-timeBegin== && n==) {
cout << "Your time have "<< <<" s"<< endl;//输出倒计时
n=;
}
else if(time()-timeBegin>=){//时间过去30秒,进行其他操作
timeBegin = time();
n=;break;
//调用其他方法进行其他操作
}
}
}
int main(){
cout<<in();
}
最新文章
- 在oneAPM参加第一个项目小结
- Linux 终端常用快捷键
- ASP.NET之Cookie(坑爹的Response.Cookies.Remove)(转)
- RPCL(Rival Penalized Competitive Learning)在matlab下的实现
- python——批量下载图片
- Bluetooth ATT介绍
- ACdream 1104 瑶瑶想找回文串(SplayTree + Hash + 二分)
- java_stack
- centos 配置NFS服务器
- 安装npm及cnpm(Windows)
- 2017年AR大会上海站干货分享
- Wireshark使用介绍(一):Wireshark基本用法
- 深入理解mybatis原理, Mybatis初始化SqlSessionFactory机制详解(转)
- poi excel 加粗
- centos7.2使用rpm安装jdk8
- 在 windows 开发 reactNative 的环境 搭建过程 react-native-android
- CTF-练习平台-Misc之 Linux基础1
- Android Bander设计与实现 - 设计
- ListenableFuture in Guava
- JQuery实现获取多个input输入框的值,并存放在一个数组中
热门文章
- Hibernate-ORM:01.Hibernate恍如隔世般初见
- Linux 下 PHP 扩展Soap 编译安装
- python基础&mdash;&mdash;重访类型分类
- [转] Bash脚本:怎样一行行地读文件(最好和最坏的方法)
- What to do when Enterprise Manager is not able to connect to the database instance (ORA-28001)
- C#操作Excel文件(转)
- C++学习014函数值传递和地址传递
- C++学习009预处理器指令符号 # ## #@ 符号的使用
- DOM操作相关案例 模态对话框,简易留言板,js模拟选择器hover,tab选项卡,购物车案例
- node + npm 命令