TAG:
//灌水代码 #include<iostream> #include<cmath> #include<fstream> using namespace std; #define pai 3.141592654 //无聊小游戏************************************* class Game{ int distance(double,double); int height(double,double); public: void playgame1(); }; int Game::distance(double angle,double fire){ double *time=new double; double anglerad;anglerad=angle*(pai/180); double distance=0; double *g=new double;*g=10; *time=(fire*sin(anglerad))/(*g)*2; distance=(*time)*(fire*cos(anglerad)); delete time;delete g; return (int)distance; } int Game::height(double angle,double fire){ double *time=new double; double anglerad;anglerad=angle*(pai/180); double height=0; double *g=new double;*g=10; height=(fire*sin(anglerad))*(fire*sin(anglerad))/(2*(*g)); delete time;delete g; return (int)height; } void Game::playgame1(){ double angle,fire; int distan; cout<<"与目标距离:";cin>>distan; while(1){ angle=0;fire=0; cout<<"与目标距离"<<distan<<"米"<<endl; cout<<"输入倾角和火力大小:";cin>>angle>>fire; if(distance(angle,fire)==distan){ cout<<"目标摧毁!"<<endl;break;} if(distance(angle,fire)==0){ cout<<"你被摧毁!"<<endl;break;} else{ cout<<"没有击中!"<<endl; cout<<"与目标相距"<<"\\t"<<"\\t"<<distan-distance(angle,fire)<<"米"<<endl; cout<<"最大高度"<<"\\t"<<"\\t"<<height(angle,fire)<<"米"<<endl;} } }//************************************* class Linux{ void help(); void ls_(); void ls_la(); void who(); void ping_loopback(); void vi(); public: void playlinux(); }; //************************************* void Linux::help() { cout<<"可用指令:ls,who,ping,vi"<<endl; } void Linux::vi() { char a[50]; ofstream outobj("buffer.txt"); cout<<"--->";cin.getline(a,50); for(int k=0;k<=strlen(a);k++) outobj.put(a[k]); } void Linux::who() { cout<<"root tty1 Dec 30 17:30"<<endl; } void Linux::ls_() { cout<<"anaconda-ks.cfg install.log bin(可执行)"<<endl; } void Linux::ls_la() { cout<<"-rw-r--r-- 1 root root 1266 Dec 16 18:59 anaconda-ks.cfg"<<endl; cout<<"-rw-r--r-- 1 root root 234 Dec 16 18:59 install.log"<<endl; cout<<"-rw-r-xr-x 1 root root 720 Dec 16 18:59 bin"<<endl; cout<<"-rw-r-xr-x 1 root root 720 Dec 16 18:59 game"<<endl; } void Linux::ping_loopback() { int n=0; while(n<=100000000)n++; cout<<"64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.073ms"<<endl; n=0; while(n<=100000000)n++; cout<<"64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.011ms"<<endl; n=0; while(n<=100000000)n++; cout<<"64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.009ms"<<endl; n=0; while(n<=100000000)n++; cout<<"64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.008ms"<<endl; cout<<""<<endl; cout<<""<<endl; cout<<"\\v--- 127.0.0.1 ping statistics ---\\v"<<endl; cout<<"4 packet transmitted, 14 received, 0% packet loss, time 1111ms"<<endl; cout<<"rtt min/arg/max/mdev = 0.008/0.012/0.067/0.015ms,pipe 2"<<endl; } void Linux::playlinux() { cout<<"Fedora Core release 1 (Yarrow)"<<endl; cout<<"Kernel 2.4.22-1.2115 nptl on an i686"<<endl; string username; for(int i=1;i<=4;i++) { cout<<"Localhost login:\\a"; cin>>username; cout<<"Password:\\r"; if(username=="root")break; if(i==4){cout<<"退出"<<endl;break;} } cout<<"Last login : Sun Dec 25 12:31:07 on tty1"<<endl; while(1){ string command; cout<<"[root@localhost root]#"; getline(cin,command); if(command=="game"){ Game one; one.playgame1(); } else if(command=="")cout<<"Welcome!Please continue.."<<endl; else if(command=="vi")vi(); else if(command=="who")who(); else if(command=="ls -la")ls_la(); else if(command=="ls")ls_(); else if(command=="ping 127.0.0.1")ping_loopback(); else if(command=="?")help(); else if(command=="exit"){cout<<"退出"<<endl;break;}else{ cout<<"-bash:"<<command<<":command not found input ? for help"<<endl; } } } //********************************************** int main() { Linux a; a.playlinux(); return 0; } (iwgh) |