#include "conio.h" |
#include "windows.h" |
#include "iostream" |
#include "string" |
#include "ctime" |
#include <sstream> |
using namespace std; |
void delay( int tm ) // 延时函数:毫秒 |
{ long t0= clock (); while ( clock ()-t0< tm ); } |
string int2string( int k) //整数转成字符串 |
{stringstream ss;ss<<k; return ss.str(); } |
void Fsorry(string st) |
{ for ( int i=0;i<st.length();i++) |
{cout<<st[i];delay(100);} cout<<endl; |
} |
void Fmem(string st= "" ) |
{st= "系统功能通过对应的字母选择,大小写均可!" ; |
for ( int i=0;i<st.length();i++) |
{cout<<st[i];delay(100);} cout<<endl; } |
void Fnow(string st= "" ) |
{ long now= time (NULL);string stw= "日一二三四五六" ; |
struct tm *t= localtime (&now); |
st= "现在是" +int2string(1900+t->tm_year)+ "-" + |
int2string(t->tm_mon+1)+ "-" +int2string(t->tm_mday)+ |
" " +int2string(t->tm_hour)+ ":" + |
int2string(t->tm_min)+ ":" +int2string(t->tm_sec)+ |
" 星期" +stw.substr(t->tm_wday*2,2); |
for ( int i=0;i<st.length();i++) |
{cout<<st[i];delay(100);} cout<<endl; } |
void Fabout(string st) |
{st= "Copyright gxx@69222.hbuas.cn 2017-1-15 " ; |
for ( int i=0;i<st.length();i++) |
{cout<<st[i];delay(100);} cout<<endl; |
} |
char getMenuK( int n) //返回指定范围内的选择字符 |
{string st= "0ABCDEFGHIJKLMNOPQRST" ;st=st.substr(0,n); |
char ch; |
do { ch=getch(); if (ch== '0' ) return ch; |
if (( int )st.find(ch)==-1) ch-= 'a' - 'A' ; } |
while (( int )st.find(ch)==-1); |
return ch; } |
void showMenu(string menu[], int n) //显示主菜单 |
{ system ( "cls" ); int i; |
cout<< " 欢迎使用【*****】系统\n" ; |
for (i=1;i<n;i++) cout<<menu[i]; |
cout<<menu[0]; } |
void main() |
{ string menu[6]={ |
"退出(0)\n (Press:A/B/.../0)\n" , |
"文件> menu1(A) menu2(B) menu3(C) menu4(D)\n" , |
"编辑> menu5(E) menu6(F) menu7(G)\n" , |
"运行> menu8(H) menu9(I) menu10(J) menu11(K) menu12(L)\n" , |
"工具> menu13(M) 现在时间(N)\n" , |
"帮助> 使用说明(O) 关于(P)\n" }; |
void (*pfun[17])(string); //使用函数指针(数组)指向特定的函数 |
for ( int i=1;i<17;i++) pfun[i]=&Fsorry; |
pfun[14]=&Fnow; pfun[15]=&Fmem; pfun[16]=&Fabout; |
while (1) |
{ char y;showMenu(menu,6); |
y=getMenuK(17); |
if (y== '0' ) {cout<< "\tThank You...Bye..." ; return ;} |
string st; |
st= "^_^抱谦,menu" +int2string(y- 'A' +1)+ "对应的模块还在创建中^_^" ; |
pfun[y- 'A' +1](st);delay(1000); |
} |
} |