C++中的各种“神奇”东西
将光标放到任意的位置
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();
}
C++中的各种“神奇”东西的更多相关文章
- #define中 #与##的神奇用法linux学习 (转)
#define中 #与##的神奇用法linux学习 (转) #define f(a,b) a##b #define d(a) #a #define s(a) d(a) void main( void ...
- Web开发中需要了解的东西
在StackExchange上有人问了这样一个问题:What should every programmer know about web development?(关于Web开发,什么是所有程序员需 ...
- Web开发中需要了解的东西【转载】
在StackExchange上有人问了这样一个问题:What should every programmer know about web development?(关于Web开发,什么是所有程序员需 ...
- Ubuntu中类似任务管理器的东西?
Ubuntu里面有没有类似windows中任务管理器的东西呢?怎么打开?谢谢!!! ================================ 检举| 2009-02-01 16:50提问者 ...
- TCP中需要了解的东西
1.TCP是一个流协议. TCP跟UDP不一样的是,TCP发送过去的东西是stream,也就是说第一次发送的跟第二次发送的数据包可能会粘在一起,即所谓的粘包问题 http://blog.csdn.ne ...
- python类中的一些神奇方法
__str__:用于在print(对象)时,直接打印__str__的返回值 class Animal: def __init__(self, name): self.name = name def _ ...
- WP中一些耗时的东西
MediaPlayer.GameHasControl 耗时1.5ms MediaPlayer.State 耗时0.4ms 上面两个原本放在游戏的update中,后来注释掉发现其它的游戏逻辑只要0.2m ...
- 基于tomcat7 web开发中的一点小东西
控制台: org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one JAR was scanned for TL ...
- #define中 #与##的神奇用法
本文整理自csdn. #define f(a,b) a##b #define d(a) #a #define s(a) d(a) void main( void ) { puts(d ...
随机推荐
- Mysql自学笔记
SQL(strucut query language) DDL (数据库定义语言)DML (数据库操作语言)DCL (数据库的控制语言)DTL (数据库的高级语言)查看版本的函数select vers ...
- 【数据结构】 List 简单实现
public class XList<T> : IEnumerable, IEnumerator { #region List 简单实现 /// <summary> /// 存 ...
- jmeter4.0☞如何汉化(二)
如何汉化jmeter打开jmeter,选择options_choose language_Chinese(simplified),如下图: 刚刚下载使用jmeter4.0的时候有点懵圈,英语实在是差劲 ...
- 推荐5个机器学习Python 库,国内外评价超高
机器学习令人无比神往,但从事这个工作的人可能并不这么想. 机器学习的工作内容往往复杂枯燥又困难——通过大量重复工作进行提升必不可少: 汇总工作流及传输渠道.设置数据源以及在内部部署和云部署的资源之间来 ...
- spring boot 打包问题
一.jar包 1.maven build package 2.linux 下执行 java -jar & 命令后台运行,也可加入服务运行 二.war包 1.将pom中的<packagin ...
- BufferedInputStream/BufferedOutputStream
BufferedInputStream: public synchronized int read() throws IOException int res=bis.read(); System.ou ...
- lintcode-62-搜索旋转排序数组
62-搜索旋转排序数组 假设有一个排序的按未知的旋转轴旋转的数组(比如,0 1 2 4 5 6 7 可能成为4 5 6 7 0 1 2).给定一个目标值进行搜索,如果在数组中找到目标值返回数组中的索引 ...
- C - 安装雷达
C - 安装雷达 Time Limit: 1000/1000MS (C++/Others) Memory Limit: 65536/65536KB (C++/Others) Problem Descr ...
- 隐马尔可夫模型HMM
隐马尔可夫模型HMM的探究 1 HMM基本概念1.1 定义1.2 观测序列生成过程1.3 HMM的三个问题2 概率计算算法2.1 直接计算算法2.2 前向算法forward algorithm2.3 ...
- 【bzoj3940】[Usaco2015 Feb]Censoring AC自动机
题目描述 Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so they h ...