.


:




:

































 

 

 

 


, .

9:

++.

 

 

++ . , , , .

 

 

1.

.

 

1- .

1-.

 

 

1-.

1-.

1-.

 

. 2.

 

#include <conio.h>

#include <iostream>

#include <string.h>

#include <stdlib.h>

#include <fstream>

#include <iomanip>

#include <stdio.h>

#include <ConsoleColor.h>

using namespace std;

struct games

{

char name[30];

int razmer;

int stoimost;

int operativa;

};

int main()

{

FILE * f;

char file[20],q,str[500],mas[200];

ofstream fin;

int a=1,s=0,g=0,h=0,j=0,k,l,sum,n;

games z[50],x[50];

 

do

{

printf("Vedite imya faila dlya chteniya:");

cin>>file;

f=fopen(file,"rt");

}

while(f==NULL);

printf("\nSoderzhimoe faila: \n");

do

{

q=getc(f);

printf("%c",q);

str[s]=q;

s++;

}

while(q!=33);

fcloseall();

 

j=0;

for(n=0;n<s;n++)

{

for(n;str[n]!=10 && n<s;n++)

{

if(a==1 && str[n]!=32)

{

g=0;

while(str[n]!=32)

{

q=str[n];

z[j].name[g]=q;

g++;

n++;

}

z[j].name[g]=NULL;

a=2;

2- .

}

if(a==2 && str[n]!=32)

{

g=0;

while(str[n]!=32)

{

q=str[n];

mas[g]=q;

g++;

n++;

}

sum=0;

h=1;

do

{

g--;

k=mas[g];

k=char(k);

l=(k-48)*h;

sum=sum+l;

h=h*10;

}

while(g>0);

z[j].razmer=sum;

a=3;

}

 

if(a==3 && str[n]!=32)

{

while(str[n]!=32)

{

q=str[n];

mas[g]=q;

g++;

n++;

}

sum=0;

h=1;

do

{

g--;

k=mas[g];

k=char(k);

l=(k-48)*h;

sum=sum+l;

h=h*10;

}

while(g>0);

z[j].operativa=sum;

a=4;

}

 

if(a==4 && str[n]!=32)

{

while(str[n]!=32)

{

q=str[n];

mas[g]=q;

g++;

n++;

}

sum=0;

h=1;

do

{

2-.

g--;

k=mas[g];

k=char(k);

l=(k-48)*h;

sum=sum+l;

h=h*10;

}

while(g>0);

z[j].stoimost=sum;

a=5;

}

}

a=1;

j++;

}

cout<<endl<<endl;

cout.width(15);cout<<green<<"Nazvanie";

cout.width(15);cout<<"razmer igry";

cout.width(15);cout<<"min kol/vo DDR";

cout.width(15);cout<<"Stoimost"<<white<<endl;

 

for(n=0;n<j;n++)

{

cout.width(15);cout<<z[n].name;

cout.width(15);cout<<z[n].razmer;

cout.width(15);cout<<z[n].operativa;

cout.width(15);cout<<z[n].stoimost<<"\n";

}

 

printf("\nVybor paramrtra sortirovki:");

printf("\n1-po razmery;\n2-po operative;\n3-po tcsene;\n");

cout<<green;

cin>>s;

cout<<white;

 

if(s==1)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].razmer<z[a].razmer)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

}

}

 

if(s==2)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].operativa<z[a].operativa)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

}

2-.

}

 

if(s==3)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].stoimost<z[a].stoimost)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

}

}

cout<<endl<<endl;

cout.width(15);cout<<green<<"Nazvanie";

cout.width(15);cout<<"razmer igry";

cout.width(15);cout<<"min kol/vo DDR";

cout.width(15);cout<<"Stoimost"<<endl<<white;

 

for(n=0;n<j;n++)

{

cout.width(15);cout<<z[n].name;

cout.width(15);cout<<z[n].razmer;

cout.width(15);cout<<z[n].operativa;

cout.width(15);cout<<z[n].stoimost<<"\n";

}

printf("\nVybor paramrtra sortirovki:");

printf("\n1-po razmery;\n2-po operative;\n3-po tcsene;\n");

cout<<green;

cin>>s;

cout<<white;

 

if(s==1)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].razmer<z[a].razmer)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

}

}

 

if(s==2)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].operativa<z[a].operativa)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

2-.

}

}

 

if(s==3)

{

for(n=0;n<(j-1);n++)

{

for(a=n+1;a<j;a++)

{

if(z[n].stoimost<z[a].stoimost)

{

x[1]=z[n];

z[n]=z[a];

z[a]=x[1];

}

}

}

}

cout<<endl<<endl;

cout.width(15);cout<<green<<"Nazvanie";

cout.width(15);cout<<"razmer igry";

cout.width(15);cout<<"min kol/vo DDR";

cout.width(15);cout<<"Stoimost"<<endl<<white;

 

for(n=0;n<j;n++)

{

cout.width(15);cout<<z[n].name;

cout.width(15);cout<<z[n].razmer;

cout.width(15);cout<<z[n].operativa;

cout.width(15);cout<<z[n].stoimost<<"\n";

}

}

 

2-.

 

 

 

 

3,4.

:

3- .

 

 

4- .

 

 

++. . , . .

 

 

1. : C++: . . .:

, 2005. 672.

 



<== | ==>
: | FAQ
:


: 2017-01-28; !; : 300 |


:

:

.
==> ...

1423 - | 1396 -


© 2015-2024 lektsii.org - -

: 0.028 .