⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cominfo.h

📁 simulation for computer selection
💻 H
字号:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void xca1(char xch);
 xdraw();
long float xconvertstr();
 long float xcomi[20],xcomc[20],xcom;int xz=0,xz1=0;
int xi=0,xn=0,xk;
int xx=130,xl=130,xt=155,xr=230,xb=165,xy=153;
char xnum[20];
cominfo()
{
  char xch,xtempstr[20];
  char *xc;
  int xn1=0;
  int gm=VGAHI,gd=VGA;

	initgraph(&gd,&gm,"c:\\tc\\bgi");
   int xesc=0,xflag=0,xcount=-1;
   cleardevice();
   xdraw();
  for(;;)
  {      fflush(stdin);
	 fflush(stdout);
	xch=getch();
      if(xch=='0'||xch=='1'||xch=='2'||xch=='3'||xch=='4'||xch=='5'||xch=='6'||xch=='7'||xch=='8'||xch=='9'||xch=='.')
	{
	if((xch=='.')&&(xflag==0))
	       {xflag=1;
	      xnum[xn]=xch;
		xn++;
	       xca1(xch);

	       xcount=0;
		}
	if((xch!='.')&&(xcount<6))
	       {
	      xnum[xn]=xch;
		xn++;
	       xca1(xch);

	      xi=xi+7;
		       xcount++;
		}
	}
	if(xch=='\b')
	{
	  moveto(xx,xy);
	   setfillstyle(1,BLACK);
	  bar(xl,xt,xr,xb);
	  xcount=-1;xflag=0;xi=0,xn=0;
	 }


	if((xch=='\r')&&(xn!=0))
	{
	    xnum[xn]='\0';
      //	strcpy(tempstr,num);
      xcom=xconvertstr();
      xcomc[xz]=xcom;
	 xn1++;
	if(xn1==(xk*2)){break;}
	xesc++;
	if(xesc%2!=0)
	{
	xcomi[xz1]=xcom;
	xz1++;
		xx=xx+150;
	xcount=-1;xflag=0;xi=0;
	xr=xr+150;xl=xl+150;
	}else
	{
	 xcomc[xz]=xcom;
	 xz++;
	xl=130,xr=230;
	xx=130;
	xy=xy+15;
	xcount=-1;xflag=0;xi=0;
	xt=xt+15;xb=xb+15;
	}

       xn=0;
	}

  }
 // printf("the string is %s",tempstr);
// for(xi=0;xi<xk;xi++)
// {
//  printf("\nthe %d computer is %f",xi,xcomi[xi]);
 // printf("\nthe %d computer cost is %f",xi,xcomc[xi]);
// }
  getch();

}

 void xca1(char xch)
  {

	   moveto(xx+xi,xy);
	       settextstyle(2,0,4);
	       setcolor(24);
	       switch(xch)
	       {
	       case'0' : outtext("0");break;
	       case'1' : outtext("1");break;
	       case'2' : outtext("2");break;
	       case'3' : outtext("3");break;
	       case'4' : outtext("4");break;
	       case'5' : outtext("5");break;
	       case'6' : outtext("6");break;
	       case'7' : outtext("7");break;
	       case'8' : outtext("8");break;
	       case'9' : outtext("9");break;
		case'.' : outtext(".");break;
	     }
	     if(xch=='.')
	     {xi=xi+3;}else{xi=xi+0.8;}
  }

  xdraw()
  {

   printf("enter the number of computer:");
  scanf("%d",&xk);
   cleardevice();
 settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(175,40,"COMPUTER INFORMATION");
 line(173,70,450,70);
  setcolor(LIGHTMAGENTA);
line(5,5,637,5);
line(5,5,5,470);
line(5,470,637,470);
line(10,10,630,10);
line(10,10,10,465);
line(10,465,630,465);
line(630,465,630,10);
line(637,470,637,5);
settextstyle(2,0,5);
setcolor(4);
fillellipse(25,90,3,3);
outtextxy(40,80,"Enter the processing speed of computer on first coloumn");
fillellipse(25,110,3,3);
outtextxy(40,100,"Enter the cost of computer on second coloumn");
setcolor(8);
outtextxy(140,130,"SPEED");
line(139,145,178,145);
setcolor(8);
outtextxy(300,130,"COST");
line(299,145,329,145);
	 int xno=100,xl1=0;
	  char xst[10];
	   settextstyle(2,0,2);
	       setcolor(11);
	       for(int xi1=1;xi1<=xk;xi1=xi1+1)
	       {
	     itoa(xi1,xst,10);
	     outtextxy(110,155+xl1,xst);
	      outtextxy(115,155+xl1,"-->");
	       xl1=xl1+15;
		}


  }



long float  xconvertstr()
 {          int xfk=0;           char xstr1[10],xstr2[10];
  int xlen=strlen(xnum);
  for(int xfi=0;((xfi<xlen)&&(xnum[xfi]!='.'));xfi++)
  {  xstr1[xfi]=xnum[xfi];}
  xstr1[xfi]='\0';
  for(int xfj=xfi+1;xfj<xlen;xfj++)
  { xstr2[xfk]=xnum[xfj];xfk++;}
  xstr2[xfk]='\0';
   int xmul=xlen-(xfi+1);
  long float xtemp=0;
 for(int xfx=0;xfx<xfi;xfx++)
 {
  switch(xstr1[xfx])
  {
   case '0':xtemp=xtemp*10;xtemp=xtemp+0;break;
   case '1':xtemp=xtemp*10;xtemp=xtemp+1;break;
   case '2':xtemp=xtemp*10;xtemp=xtemp+2;break;
   case '3':xtemp=xtemp*10;xtemp=xtemp+3;break;
   case '4':xtemp=xtemp*10;xtemp=xtemp+4;break;
   case '5':xtemp=xtemp*10;xtemp=xtemp+5;break;
   case '6':xtemp=xtemp*10;xtemp=xtemp+6;break;
   case '7':xtemp=xtemp*10;xtemp=xtemp+7;break;
   case '8':xtemp=xtemp*10;xtemp=xtemp+8;break;
   case '9':xtemp=xtemp*10;xtemp=xtemp+9;break;

   }
  }
 // printf("the float value of temp1  %f",xtemp);
 long float xfl1=xtemp;
 xtemp=0.0;
for(xfx=0;xfx<(xlen-(xfi+1));xfx++)
 {
  switch(xstr2[xfx])
  {
   case '0':xtemp=xtemp*10;xtemp=xtemp+0;break;
   case '1':xtemp=xtemp*10;xtemp=xtemp+1;break;
   case '2':xtemp=xtemp*10;xtemp=xtemp+2;break;
   case '3':xtemp=xtemp*10;xtemp=xtemp+3;break;
   case '4':xtemp=xtemp*10;xtemp=xtemp+4;break;
   case '5':xtemp=xtemp*10;xtemp=xtemp+5;break;
   case '6':xtemp=xtemp*10;xtemp=xtemp+6;break;
   case '7':xtemp=xtemp*10;xtemp=xtemp+7;break;
   case '8':xtemp=xtemp*10;xtemp=xtemp+8;break;
   case '9':xtemp=xtemp*10;xtemp=xtemp+9;break;

   }
  }

//  printf("the float value of temp2  %f",temp);

 long float xfl2;
 xfl2=xtemp;

 switch(xmul)
 {
  case 1: xfl2=xfl2/10;break;
  case 2: xfl2=xfl2/100;break;
  case 3: xfl2=xfl2/1000;break;
  case 4: xfl2=xfl2/10000;break;
  case 5: xfl2=xfl2/100000;break;
  case 6: xfl2=xfl2/1000000;break;

 }

  //printf("the float value of tot  %f",fl1);
 //fl2=fl2/float(mul);
 long float xfinf=xfl1+xfl2;
  for(int xp1=0;xp1<xlen;xp1++)
   {
   xnum[xp1]='\0';
   }
 //printf("the float value is %f",xfinf);
 return xfinf;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -