close

Вход

Забыли?

вход по аккаунту

?

отчет

код для вставкиСкачать
???????????? ??????????? ? ????? ?????????? ?????????
??????????? ??????????????? ????????? ??????????????? ??????????
??????? ????????????????? ???????????
"???????? ??????????????? ??????????? ???????????
????? ?. ?. ???????????"
????? ?? ???????? ??????
?? ?????????? "????????-??????????????? ????????????????"
????????: ??????? ??. ?03-781-1
??????? ?.?.
??????: ?????????????
??????? ?.?.
??????, 2012 ?.
???? ??????. ????????? ?????? ? ??????, ?????????? ? ???? ???????? ?????????? "????????-??????????????? ????????????????".
???????. ??????????? ???? ?????? ????????? ????? ??????.
?????? ??????????:
St1 - ???????????? ??????;
St3 - ???????????? ?????? ??? ???????? ?????????? ??? ??????????;
Max - ?????? ??????;
????? ?????????:
#include "stdafx.h"
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
#include "conio.h"
struct stud{
int nom;
char surname[25]; //??????? ????????
char name[15];//??? ????????
int rost;//???? int mas; };//?????
int i,g,n,max,nomUd,nomD,rrost,mmas,l1,l2,pr1;
FILE *f;
stud st1[40],st2[1],st3[40];
void menu()
{printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | |\n");
printf(" | MENU |\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | 1 - PROCHITATb FILE |\n");
printf(" | 2 - BbIBOD SPISKA |\n");
printf(" | 3 - BbIBOD MENU |\n");
printf(" | 4 - DOBAVITb STROKU |\n");
printf(" | 5 - UDALITb STROKU |\n");
printf(" | 6 - IZMENITb STROKU |\n");
printf(" | 7 - POISK PO 2-um POL9M |\n");
printf(" | 8 - SORTIROVKA |\n");
printf(" | 9 - COXPAHITb B FILE |\n");
printf(" | 0 - BbIXOD |\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n\n\n"); }
void read(){//?????? ?????
f=fopen("D:\\?????\\2 ????\\3 ???????\\???\\??????\\spisok.txt","r+t");
if(f== NULL){printf("\n\n FILE NOT FOUND!!!\n\n");return;}
i=1;while (!feof(f)){ //???? ?? ????? ?????? ????
st1[i].nom=i;
fscanf(f, "%s %s %d %d", st1[i].surname, &st1[i].name, &st1[i].rost, &st1[i].mas); i++;};
max=i;
printf(" ");for (i=0;i<n;i++){printf("_");};
printf("\n | |");
printf("\n | DONE! |");
printf("\n |");for (i=0;i<n-2;i++){printf("_");};printf("|\n\n\n");
max-=1; }
void vivod(){//????? ?????? ?? ?????
printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | SPISOK GRUPPbI B03-781-1 |\n");
printf(" |"); for (i=0;i<n-2;i++){printf("_");};
printf("|\n |No.| Familyia | Name | Rost| Massa|\n");
printf(" |"); for (i=0;i<n-2;i++){printf("_");};printf("|\n");
i=1; while(i<max){
printf(" |%2d |%25s | %15s | %3d | %4d |\n", st1[i].nom, st1[i].surname, st1[i].name, st1[i].rost, st1[i].mas); i++;}
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n\n\n"); }
void DOBAV() //?????????? ????? ??????
{printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | DOBAViTb |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | BBEDiTE NOMER STROKI DL9 DOBAVLENI9: "); scanf("%d",&nomD);
if (nomD>max){printf(" | |\n");
printf(" | STROKA VNE SPISKA !!! |");
printf("\n");printf(" |");
for (i=0;i<n-2;i++){printf("_");}; printf("|\n\n\n");return;}
printf(" | |\n");
printf(" | BBEDITE DAHHbIE STUDEHTA: |\n");
printf(" | |\n");
printf(" | FAMILIA(HE BOLSHE 25 simvolov): "); scanf("%s",&st2[1].surname);
printf(" | NAME(HE BOLSHE 15 simvolov): "); scanf("%s",&st2[1].name);
printf(" | ROST: "); scanf("%d",&st2[1].rost);
printf(" | MASSA: "); scanf("%d",&st2[1].mas);
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|");
for(g=max;g>nomD;g--){
strcpy(st1[g].surname,st1[g-1].surname); //??????????? ??????
strcpy(st1[g].name,st1[g-1].name);
st1[g].rost=st1[g-1].rost;
st1[g].mas=st1[g-1].mas; };
st1[max].nom=max;max+=1;
//?????????? ? ??????
strcpy(st1[nomD].surname,st2[1].surname);
strcpy(st1[nomD].name,st2[1].name);
st1[nomD].rost=st2[1].rost;st1[nomD].mas=st2[1].mas;
printf("\n | |");
printf("\n | DONE! |");
printf("\n |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n\n\n");}
void UDAL() //???????? ??????
{printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | UDALITb |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | BBEDiTE NOMER STROKI DL9 UDALENI9: ");
scanf("%d",&nomUd); //?????? ?????? ?????? if (nomUd>=max){printf(" | |\n");
printf(" | STROKA VNE SPISKA !!! |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n\n\n"); return; }
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|");
//????????
for(max=max;nomUd<max;nomUd++){
strcpy(st1[nomUd].surname,st1[nomUd+1].surname);
strcpy(st1[nomUd].name,st1[nomUd+1].name);
st1[nomUd].rost=st1[nomUd+1].rost;
st1[nomUd].mas=st1[nomUd+1].mas; };
max-=1; printf("\n | |");
printf("\n | DONE! |");
printf("\n |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n\n\n");}
void IZMEN()//????????? ??????
{printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | IZMENENIE |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | BBEDiTE NOMER STROKI DL9 IZMENENI9: "); scanf("%d",&nomD);
if (nomD>=max){printf(" | |\n");
printf(" | STROKA VNE SPISKA !!! |");
printf("\n");printf(" |");
for (i=0;i<n-2;i++){printf("_");}; printf("|\n\n\n");return;}
printf(" |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n | Familyia | Name | Rost| Massa|\n");
printf(" | %25s | %15s | %3d | %4d |\n", st1[nomD].surname, st1[nomD].name, st1[nomD].rost, st1[nomD].mas);
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | XOTITE IZMENITb: |\n");
printf(" | FAMILIYU - NAZHMITE 1 NAME - NAZHMITE 2 |\n");
printf(" | ROST - NAZHMITE 3 MASSU - NAZHMITE 4 |\n");
printf(" | BbIXOD - NAZHMITE 0 |\n");
printf(" | |\n");int p=0;
while (p!=2){char a = getch();
switch (a){
case '1':
printf(" | VVEDITE NOVUIU FAMILIIU(< 25 simvolov): "); scanf("%s",&st1[nomD].surname);
printf(" | DONE! |\n");continue;
case '2':
printf(" | VVEDITE NOVOE IM9: "); scanf("%s",&st1[nomD].name);
printf(" | DONE! |\n"); continue;
case '3':
printf(" | VVEDITE NOVII ROST: "); scanf("%d",&st1[nomD].rost);
printf(" | DONE! |\n");continue;
case '4':
printf(" | VVEDITE NOVUIU MASSU: "); scanf("%d",&st1[nomD].mas);
printf(" | DONE! |\n");continue;
case '0':
printf(" | DONE! |");
printf("\n |");for (i=0;i<n-2;i++){printf("_");};printf("|\n\n\n");p=2;
}}}
void POISK()//????? ?? ???? ?????
{ for(i=1;i<max;i++){ //??????? ??????? ?? "??????"
strcpy(st3[i].surname,"");strcpy(st3[i].name,""); st3[i].rost=0; st3[i].mas=0;}
printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | POISK PO 2-um POL9M |"); printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | XOTITE NAI'TI PO: |\n");
printf(" | FAMILIII - VVEDITE 1 IMENI - VVEDITE 2 |\n");
printf(" | ROSTU - VVEDITE 3 MASSE - VVEDITE 4 |\n");
printf(" | |\n");
printf(" | VVEDITE DVA ZNACHENI9: |\n");
printf(" | |\n");printf(" | ");
scanf("%d",&l1);
if ((l1>=5) || (l1<=0)){printf(" | ERROR! |\n");
printf(" ");for (i=0;i<n;i++){printf("_");};
printf("\n\n\n");return;} printf(" | ");
scanf("%d",&l2);
if ((l2>=5) || (l2<=0)||(l1==l2)){printf(" | ERROR! |\n");
printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n\n\n");return;}
printf(" | |\n");
if ((l1==1)||(l2==1)){
printf(" | VVEDITE FAMILIY DL9 POISKA: ");
scanf("%s",st2[1].surname);
i=1; pr1=0;while(i<max){
if(!strcmp(st1[i].surname,st2[1].surname)) {pr1=1;
strcpy(st3[i].surname,st1[i].surname);};i++;}}
if ((l1==2)||(l2==2)){printf(" | VVEDITE IM9 DL9 POISKA: ");
scanf("%s",st2[1].name);i=1; pr1=0;
while(i<max){if(!strcmp(st1[i].name,st2[1].name)) {pr1=1;
strcpy(st3[i].name,st1[i].name);};i++;}}
if ((l1==3)||(l2==3)){printf(" | VVEDITE ROST DL9 POISKA: ");
scanf("%d",&st2[1].rost);
i=1; pr1=0;while(i<max){if(st1[i].rost==st2[1].rost)
{pr1=1; st3[i].rost=st1[i].rost;};i++;}}
if ((l1==4)||(l2==4)){printf(" | VVEDITE MASSU DL9 POISKA: ");
scanf("%d",&st2[1].mas);i=1; pr1=0;
while(i<max){if(st1[i].mas==st2[1].mas) {pr1=1;
st3[i].mas=st1[i].mas;}; i++;}}
if(pr1==0){printf(" | |\n");
printf(" | NOT FOUND |\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n\n\n");return;}
for(i=1;i<max;i++){//?? ??????? ????
if(strcmp(st3[i].surname,"")){if((strcmp(st3[i].name,""))||(st3[i].rost!=0)||(st3[i].mas!=0)) {st3[i].nom=i;} }
//?? ??????? ????
if(strcmp(st3[i].name,"")){if ((strcmp(st3[i].surname,""))||(st3[i].rost!=0)||(st3[i].mas!=0)){st3[i].nom=i;} }
//?? ???????? ????
if(st3[i].rost!=0){if ((strcmp(st3[i].surname,""))||(strcmp(st3[i].name,""))||(st3[i].mas!=0)){st3[i].nom=i;} }
//?? ?????????? ????
if(st3[i].mas!=0){if ((strcmp(st3[i].surname,""))||(st3[i].rost!=0)||(strcmp(st3[i].name,""))){st3[i].nom=i;} }}
//?????
printf(" | |\n");
printf(" | CTYDEHT(bI) HAIDEH(bI): |\n");
for(i=1;i<max;i++){if(st3[i].nom==st1[i].nom){
printf(" |%2d |%25s | %15s | %3d | %4d |\n", st1[i].nom, st1[i].surname, st1[i].name, st1[i].rost, st1[i].mas);}}printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n\n\n"); }
void SS(){//??????? ??????????
strcpy(st2[1].surname,st1[i].surname);
strcpy(st1[i].surname,st1[g].surname);
strcpy(st1[g].surname,st2[1].surname);
strcpy(st2[1].name,st1[i].name);
strcpy(st1[i].name,st1[g].name);
strcpy(st1[g].name,st2[1].name);
st2[1].rost=st1[i].rost;
st1[i].rost=st1[g].rost;
st1[g].rost=st2[1].rost;
st2[1].mas=st1[i].mas;
st1[i].mas=st1[g].mas;
st1[g].mas=st2[1].mas;}
void GG(){
printf(" | DONE! |\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};
printf("|\n");}
void SORT()//?????????? ?? ?????? ????
{ printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | SORTIROVKA |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |\n");
printf(" | XOTITE SORTIROVATb PO: |\n");
printf(" | |\n");
printf(" | FAMILII - NAZHMITE 1 IMENI - NAZHMITE 2 |\n");
printf(" | ROSTU - NAZHMITE 3 MASSE - NAZHMITE 4 |\n");
printf(" | EXIT - NAZHMITE 0 |\n");
printf(" | |\n");int p=0;
while (p!=2){ char a = getch();switch (a){ case '1':for(i=1;i<max;i++){
for(g=1;g<max;g++){
if(strcmp(st1[i].surname,st1[g].surname)<0){ SS();}}}
GG();vivod();return;
case '2':for(i=1;i<max;i++){
for(g=1;g<max;g++){
if(strcmp(st1[i].name,st1[g].name)<0){SS();}}}
GG();vivod();return;
case '3': for(i=1;i<max;i++){
for(g=1;g<max;g++){
if(st1[i].rost<st1[g].rost){SS();}}}
GG();vivod();return;
case '4': for(i=1;i<max;i++){
for(g=1;g<max;g++){
if(st1[i].mas<st1[g].mas){SS();}}}
GG();vivod();return;}}}
void SAVE()//?????????? ? ????
{i=1; f=fopen( "D:\\?????\\2 ????\\3 ???????\\???\\??????\\spisok.txt", "w" );
while(i<max){fprintf(f, "%s %s %d %d\n", st1[i].surname, st1[i].name, st1[i].rost, st1[i].mas);
i++;}
printf(" ");for (i=0;i<n;i++){printf("_");};printf("\n");
printf(" | SAVE |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");
printf(" | |");printf("\n");
printf(" | COXPAHEHO! |");printf("\n");
printf(" |");for (i=0;i<n-2;i++){printf("_");};printf("|\n");}
int _tmain(int argc, _TCHAR* argv[]) //???????? ???????
{ n=63;max=-1;menu();int p=0;
while (p!=2){char a = getch();switch (a){
case '1':read(); continue;
case '2':vivod(); continue;
case '3':menu();continue;
case '4':DOBAV();continue;
case '5':UDAL();continue;
case '6':IZMEN();continue;
case '7': POISK();continue;
case '8': SORT();continue;
case '9': SAVE();continue;
case '0': p=2;
}}return 0; }
????????? ?????? ?????????:
?????? ?? ??????:
??? ????????? ????????? ??????? ? ???????? ?????? ? ??????, ?????????? ? ???? ???????? ?????????? "????????-??????????????? ????????????????".
Документ
Категория
Без категории
Просмотров
13
Размер файла
143 Кб
Теги
отчет
1/--страниц
Пожаловаться на содержимое документа