编程语言
首页 > 编程语言> > 自己随手写的电脑程序

自己随手写的电脑程序

作者:互联网

 

#include<iostream>
#include<windows.h>
#include<cstdlib>
#include<ctime>
#include<unistd.h>
#include<cmath>
#include<stdlib.h>
using namespace std;
int main()
{
	char E,G,H,I;
	int a,b,c,i,d,j,k,l,e,f,g,h,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,D,F,K;
	cout<<"是否开机?(Y,N)"<<endl;
	cin>>E;
	if(E=='y'||E=='Y') 
	{
		cout<<"电脑已开机"<<endl;
	}
	if(E=='n'||E=='N')
	{
		return 4;
	}
	else while(!(E=='y'||E=='Y'or E=='N'||E=='n'))
	{
		cout<<"无";
		cin>>E; 
		if(E=='n'||E=='N')
		{
			return 4;
		}
	}
	cout<<"输入登录密码"<<endl;
	cin>>y;
	if(y==123456789)
	{
		cout<<"欢迎"<<endl;
	}
	else
	{
		cout<<"密码错误,请重试"<<endl;
		cin>>z;
		if(z==123456789)
		{
			cout<<"欢迎"<<endl;
		}
		else
		{
			cout<<"密码错误,请重试,还有一次机会"<<endl;
			cin>>A;
			if(A==123456789)
			{
				cout<<"欢迎"<<endl;
			}
			else
			{
				cout<<"密码错误,电脑已锁定,请十秒后再试"<<endl;
				int C=10;
				for(B=1;B<=10;B++)
				{
					cout<<C<<endl;
					C=C-1;
					Sleep(1000);
				}
				cout<<"请再次输入,最后一次机会"<<endl;
				cin>>D;
				if(D==123456789)
				{
					cout<<"欢迎"<<endl;
				} 
				else
				{
					cout<<"密码错误,请离开"<<endl;
					return 3;
				}
				
			}
		} 
	}
	cout<<"是否开启屏幕(Y/N)"<<endl;
	cin>>G;
	int N;
    while(G=='Y'||G=='y')
	{ 
		cout<<"打开倒计时按1,打开画正方形器按2,打开计算器(两个数的运算)按3,打开猜数游戏按4,退出按5,其他程序按6"<<endl;
    	cin>>a;
    	if(a==5)
    	{
    		return 3;
    	}
    	if(a==6)
    	{
    		cout<<"打开分数统计器按1"<<endl;
    		cin>>K;
			if(K==1)
			{
				cout<<"请输入总人数"<<endl;
		    	int J,L,M[1000];
			    cin>>J;
		    	cout<<"请分别输入成绩"<<endl;
		    	for(L=1;L<=J;L++)
		    	{
			    	cin>>M[L];
		    	}   cout<<endl;
			  	cout<<"请输入要找的分数的编号"<<endl;
			    cin>>N;
				cout<<M[N]<<endl;
			} 
    	if(a==1)
    	{
	    	cout<<"请输入倒计时时间"<<endl;
	    	cin>>b;
	    	cout<<"再次输入时间"<<endl;
	    	cin>>c;
	    	for(i=1;i<=b;i++)
	    	{
		    	cout<<c<<endl;
		    	c=c-1;
		    	Sleep(1000);
	    	}
	    }
        if(a==2)
    	{
    		cout<<"请输入正方形边长"<<endl;
    		cin>>d;
	    	cout<<"再次输入正方形边长"<<endl;
    		cin>>k;
    		for(j=1;j<=d;j++)
    		{
        		for(l=1;l<=k;l++)
	    		{
	    			cout<<"*";
	    		}
		    	cout<<endl;
	    	}
    	}
    	if(a==3)
	    {
	    	cout<<"加法按1,减法按2,乘法按3,除法按4,取余按5"<<endl;
    		cin>>e;
	    	if(e==1)
	    	{
	    		cout<<"输入加数"<<endl;
	    		cin>>f>>g;
	    		h=f+g;
	    		cout<<g<<endl;
	    	}
	    	if(e==2)
	    	{
	    		cout<<"输入减数"<<endl;
	    		cin>>m>>n;
	    		o=m-n;
	    		cout<<o<<endl;
	    	}
	    	if(e==3)
	    	{
	    		cout<<"输入乘数"<<endl;
	    		cin>>p>>q;
	    		r=p*q;
	    		cout<<r<<endl;
	    	}
	    	if(e==4)
	    	{
	    		cout<<"输入除数(无余数)"<<endl;
	    		cin>>s>>t;
	    		u=s/t;
	    		cout<<u<<endl; 
	    	}
	    	if(e==5)
	    	{
	    		cout<<"输入取余的数"<<endl;
	    		cin>>v>>w;
	    		x=v%w;
	    		cout<<x<<endl;
	    	}
    	}
    	if(a==4)
    	{
	    	int num;
            int guess;
            char again;
            num=rand()%100;
            cout<<"0-100的数字,你猜猜会是几??"<<endl;
            do{
            cout<<"请输入一个数: "<<endl;
            cin>>guess;
            if (num==guess)
            {
                cout<<"哇,你猜对了,好聪明啊!回!"<<endl;
            }
            else if(num< guess){
            cout<<"哇, 猜大了,换个小点的!!"<<endl;
   
            }
            else if(num> guess){
              cout<<"哇, 猜小了,换个大点答的!!"<<endl;
            }
            cout<< "想继续猜吗? (Y/N)";
            cin>> again;
            } while (again== 'Y' ||again== 'y');
             system("pause");
    	}
    	cout<<"想继续使用电脑吗(Y/N)"<<endl;
    	cin>>G;
    	if(G=='n'||G=='N')
    	{
    		exit(0);
    	}
    	else while(!(G=='y'||G=='Y'or G=='N'||G=='n'))
    	{
    		cout<<"无"<<endl;
    		cin>>G;
    		if(G=='n'||G=='N')
    		{
    			exit(1);
    		}
    	}
    }
	return 3;
}}

电脑程序

注:这个程序会让你输开机密码,密码是123456789。

本程序为作者原创,未经许可,请勿转载,违者后果自负。

标签:again,guess,随手,cout,int,程序,电脑,123456789,include
来源: https://blog.csdn.net/gbrehgbrhgbjkakl/article/details/120935028