📄 com.cpp
字号:
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
#include<stdlib.h>
#include<stdio.h>
void main()
{
float M,m,k,r,comi[10],comc[10],bs[10],bc[10];
int n,o;
clrscr();
printf("enter the no of msg to process in second");
scanf("%f",&M);
printf("enter the size of recevimg message in character");
scanf("%f",&m);
printf("enter the percentage of msg that goiing to be proccesed");
scanf("%f",&k);
printf("enter the size of sending message in character");
scanf("%f",&r);
printf("enter the no of compters");
scanf("%d",&n);
printf("enter the information of the computers");
for (int i=0;i<n;i++)
{
printf("enter the %d th speed of processing",i);
scanf("%f",&comi[i]);
// printf("enter the %d th computer cost",i);
// scanf("%f",comc[i]);
}
printf("enter the no of buffer that u want to try");
scanf("%d",&o);
for(i=0;i<o;i++)
{
printf("enter the %d th buffer size",i);
scanf("%f",&bs[i]);
// printf("enter the %d th buffer cost",i);
// scanf("%f",bc[i]);
}
float y=(m+(k*r));
float x=(1000*M);
float z=(((2000*M)+(10000*M*k))/x);
float py1=2000*M;
float px1=(10000*(M*k));
float pz1=1000*M*(y);
long float p1=py1+px1+float(pz1/2);
printf("y=%f\n",y);
printf("x=%f\n",x);
printf("z=%f\n",z);
printf("y1=%f\n",py1);
printf("x1=%f\n",px1);
printf("z1=%f\n",pz1);
printf("tot=%f\n",p1);
float finc[10],finb[10];
int f;
f=0;
for(i=0;i<n;i++)
{
for(int j=0;j<o;j++)
{
if((y/bs[j])<=((comi[i]/x)-z))
{
finc[f]=comi[i];
finb[f]=bs[j];
f++;
break;
}else
{
continue;
}
}
}
for(i=0;i<f;i++)
{
printf("the %d computer is %f\n",i,finc[i]);
printf("the %d buffer is %f\n\n",i,finb[i]);
}
long int temparr[10],maxx,j=1;
for(i=0;i<o;i++)
{
temparr[i]=(y/bs[i]);
maxx=temparr[0];
while(j<o)
{
if(maxx<temparr[j])
{
maxx=temparr[j];
}
j++;
}
}
printf("the max is %d",maxx);
j=1; long float max=0;
if(f==0)
{
int xx=j;
max=comi[0];
while(j<n)
{
if(max<comi[j])
{
max=comi[j];
xx=j;
}
j++;
}
}
printf("the max is %f",max);
long float tempcom=max,tempx=tempcom;
int fla=0;i=2;
int mul=0;
if(f==0)
{
while(fla!=1)
{
tempx=tempx*i;
for(j=0;j<o;j++)
{
if((y/bs[j])<=((tempx/x)-z))
{fla=1;mul=i;break;}
}
mul++;
}
}
printf("the d is %d",mul-1);
printf("the b is %f",bs[j]);
getch();
int gm=VGAHI,gd=VGA;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
line(20,10,20,450);
line(20,450,400,450);
int x1,x2,y1,y2;
for(i=0;i<o-1;i++)
{ x1=(20+(20*bs[i])),y1=abs((10*temparr[i])-450),x2=20+(20*bs[i+1]),y2=abs((10*temparr[i+1])-450);
line(x1,y1,x2,y2);
//line(30,250,40,350);
}
for(i=0;i<o;i++)
{
int par=12,inc=10;
while(par<440)
{
line(20+(20*bs[i]),10+inc,20+(20*bs[i]),12+inc);
inc=inc+4;
par=par+4;
}
}
float hor[10];
for(i=0;i<n;i++)
{
int m=((comi[i]/x)-z);
if(m>0){hor[i]=m;}
}
for(i=0;i<n;i++)
{
int par=12,inc=10;
while(par<=400)
{
line(10+inc,abs(((10*hor[i])-450)),12+inc,abs(((10*hor[i])-450)));
inc=inc+4;
par=par+4;
}
}
int no=100,l=0;
char st[10];
settextstyle(2,0,1);
setcolor(11);
for(i=0;i<=45;i=i+1)
{
itoa(i,st,10);
line(18,450-l,20,450-l);
outtextxy(0,445-l,st);
l=l+10;
}
l=0;
for(i=0;i<=20;i=i+1)
{
itoa(i,st,10);
line(20+l,450,20+l,452);
outtextxy(17+l,455,st);
l=l+20;
}
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -