_getch一段高复用代码

来源:互联网 发布:python去除空格 编辑:程序博客网 时间:2024/04/19 10:40

按照自己的需求进一步进行修改.

#include "stdafx.h"#include <stdlib.h>#include <conio.h>int _tmain(int argc, _TCHAR* argv[]){    system("title 能否被2整除呢.按“T”键退出");    while(1)    {        int  x;        system("CLS");        printf ("输入要判断的数:");        char tmp[2];        int iPanduan=0;        while(1)        {            iPanduan=!(iPanduan);//一共有两个位置,通过这个语句使循环存储字符            tmp[iPanduan]=_getch();            putchar(tmp[iPanduan]);            switch(tmp[iPanduan])            {            case '\r':                {                     iPanduan=!iPanduan;//判断末位数字在数组中哪个位置                    x=tmp[iPanduan];                    break;                }                //按T退出            case 't':            case 'T':                {                    return 0;                    system("exit");                }            case '.':                {                //分割数据哟                }            case '0':            case '1':            case '2':            case '3':            case '4':            case '5':            case '6':            case '7':            case '8':            case '9':                {                }            }        }    }    return 0;}
0 0
原创粉丝点击