VI. C.
. , (15-20). 2-3 p .
6
( 1-11)
: , , , (, , AGP, PCI) , (SCSI/IDE, ATA/SATA), , () , .
- .
, . , ( ), ( - ) : - .
GCC. Digital UNIX DigitalAlpha DEC 21064. . , .
/users/stud/128095/temerloh/DDD/OP, AXP3. cc gcc. , .
- .
, :
1) ;
2) (, , , ).
- ( ).
:
, .
|
|
, , , .
1.
1
s | Struct | |
fam | char | |
CPU_type[10] | char | CPU |
Int_CPU | int | CPU |
Vol_mem | int | |
Type_Vid[7] | char | |
Bus_Video[7] | char | SCSI/IDE, ATA/SATA |
Video_Memory | int | |
Type_HD[7] | char | HD |
NUM_HD | int | HD |
Vol_HD | int | HD |
Int_Con | int | |
Ext_Dev | int | () |
Op_system[7] | char | |
r | int | - ( 6 ) |
q | int | ( 6 ) |
argc | int | |
*argv | char |
1
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
FILE *fi,*fo;// ,
if(argc==1)//
{ if((fi=fopen("CPU.txt","r"))==NULL)
{printf("Cannot input 1"); return 1;}
if((fo=fopen("Base.dat","wb"))==NULL)
{printf("Cannot output"); return 1;}
}
else
if(argc==2) // 3) RUN.EXE IN.TXT - NOT WORKS
{ puts(argv[1]); printf("%s\n",argv[1]);// SEE OUT2.DAT
if((fi=fopen(argv[1],"r"))==NULL)
{printf("Cannot input 2"); //getch();
return 1;}
if((fo=fopen("Base.dat","wb"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
}
else
{ if((fi=fopen(argv[1],"r"))==NULL)
{printf("Cannot input 3"); //
return 1;}
if((fo=fopen(argv[2],"wb"))==NULL)
{printf("Cannot output");
return 1;}
}
struct S
{char fam[20];
char CPU_type[10];
int Int_CPU;
int Vol_mem;
char Type_Vid[7];
char Bus_Video[7];
int Video_Memory;
char Type_HD[7];
int NUM_HD;
int Vol_HD;
int Int_Con;
int Ext_Dev;
char Op_system[7];
} s,s1;
int l=sizeof(S),n=0;
// printf("l=%d\n",l);
while(!feof(fi))
{// printf("l=%d\n",l);
fscanf(fi,"%s %s %d %d %s %s %d %s %d %d %d %d %s",s.fam,&s.CPU_type,&s.Int_CPU,&s.Vol_mem,&s.Type_Vid,&s.Bus_Video,&s.Video_Memory,&s.Type_HD,&s.NUM_HD,&s.Vol_HD,&s.Int_Con,&s.Ext_Dev,&s.Op_system);
// printf("%c %d %f",s.fam,&s.g_r,&s.rost);
fwrite(&s,l,1,fo); n++;//1- ,fo-
// printf("n=%d\n",n);
}
fclose(fi); fclose(fo);
if(argc<3)
{ if((fi=fopen("Base.dat","rb"))==NULL)
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen("out.txt","w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
}
else if(argc==3)
{ if((fi=fopen(argv[2],"rb"))==NULL)
|
|
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen("out.txt","w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
} else
{ if((fi=fopen(argv[2],"rb"))==NULL)
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen(argv[3],"w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
}
printf("==========================================================Sod basy============================================================\n");
printf("|familya |CPU_type | Int_CPU| Vol_mem| Type_Vid| Bus_Video| Video_memory| Type_HD| Num_HD| Vol_HD| Int_Con| Ext_dev|Op_system|\n");
printf("==============================================================================================================================\n");
fprintf(fo, "==========================================================Sod basy============================================================\n");
fprintf(fo, "|familya |CPU_type | Int_CPU| Vol_mem| Type_Vid| Bus_Video| Video_memory| Type_HD| Num_HD| Vol_HD| Int_Con| Ext_dev|Op_system|\n");
fprintf(fo, "==============================================================================================================================\n");
while(!feof(fi))
{// printf("l=%d\n",l);
s1=s;
fread(&s,l,1,fi);
if(strcmp(s.fam,s1.fam))
{
fprintf(fo, "|%8s|%9s|%5d |%7d | %7s | %7s | %8d | %6s |%5d | %5d | %3d | %3d | %7s |\n", s.fam,s.CPU_type,s.Int_CPU,s.Vol_mem,s.Type_Vid,s.Bus_Video,s.Video_Memory,s.Type_HD,s.NUM_HD,s.Vol_HD,s.Int_Con,s.Ext_Dev,s.Op_system);
printf("|%8s|%9s|%5d |%7d | %7s | %7s | %8d | %6s |%5d | %5d | %3d | %3d | %7s |\n",s.fam,s.CPU_type,s.Int_CPU,s.Vol_mem,s.Type_Vid,s.Bus_Video,s.Video_Memory,s.Type_HD,s.NUM_HD,s.Vol_HD,s.Int_Con,s.Ext_Dev,s.Op_system); n++;
}
}
printf("==============================================================================================================================\n");
fprintf(fo, "==============================================================================================================================\n");
return 0;
}
2
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
FILE *fi,*fo;//,
if(argc==1)
{ if((fi=fopen("Base.dat","rb"))==NULL)
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen("out.txt","w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
}
else if(argc==2)
{ if((fi=fopen(argv[1],"rb"))==NULL)
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen("out.txt","w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
} else
{ if((fi=fopen(argv[1],"rb"))==NULL)
{printf("Cannot input"); //getch();
return 1;}
if((fo=fopen(argv[2],"w"))==NULL)
{printf("Cannot output"); //getch();
return 1;}
}
struct S
{char fam[20];
char CPU_type[10];
int Int_CPU;
int Vol_mem;
char Type_Vid[7];
char Bus_Video[7];
int Video_Memory;
char Type_HD[7];
int NUM_HD;
int Vol_HD;
int Int_Con;
int Ext_Dev;
char Op_system[7];
} s,s1;
int l=sizeof(S),n=0;
int r=1, q=1; while(r)
{printf("input kol-vo Processorov(r=1-4, for end r=0):r=");
scanf("%d",&r);
printf("Memory(q=512-4096, for end q=0):q=");
scanf("%d",&q);
if(r,q)
{
fprintf(fo,"Query %d(for Int_CPU>=%d for Vol_mem>=%d):\n",++n,r,q);
printf("=====================================================Sod basy=================================================================\n");
printf("|familya |CPU type |Int_CPU |Vol_mem |Type_Vid |Bus_Video |Video_memory |Type_HD |Num_HD |Vol_HD |Int_Con |Ext_dev |Op_system|\n");
|
|
printf("==============================================================================================================================\n");
fprintf(fo, "=====================================================Sod basy=================================================================\n");
fprintf(fo, "|familya |CPU type |Int_CPU |Vol_mem |Type_Vid |Bus_Video |Video_memory |Type_HD |Num_HD |Vol_HD |Int_Con |Ext_dev |Op_system|\n");
fprintf(fo, "==============================================================================================================================\n");
}
rewind(fi);
while(!feof(fi))
{
s1=s;
fread(&s,l,1,fi);
if(strcmp(s.fam,s1.fam)) if((r&&s.Int_CPU>=r) && (q&&s.Vol_mem>=q))
{
fprintf(fo, "|%8s|%9s|%5d |%7d | %7s | %7s | %8d | %6s |%5d | %5d | %3d | %3d | %7s |\n", s.fam,s.CPU_type,s.Int_CPU,s.Vol_mem,s.Type_Vid,s.Bus_Video,s.Video_Memory,s.Type_HD,s.NUM_HD,s.Vol_HD,s.Int_Con,s.Ext_Dev,s.Op_system);
printf("|%8s|%9s|%5d |%7d | %7s | %7s | %8d | %6s |%5d | %5d | %3d | %3d | %7s |\n",s.fam,s.CPU_type,s.Int_CPU,s.Vol_mem,s.Type_Vid,s.Bus_Video,s.Video_Memory,s.Type_HD,s.NUM_HD,s.Vol_HD,s.Int_Con,s.Ext_Dev,s.Op_system);
}
}//while
if(r) {
printf("==============================================================================================================================\n");
fprintf(fo, "==============================================================================================================================\n");
}
}//while(r)
return 0;
}//main
, .
CPU.txt ( ):
Noskov Pent4 3.00 512 ext AGP 128 IDE 1 120 5 7 XP
Ivanov C2D 2.83 1024 ext PCI-E 512 SATA 3 700 5 7 XP
Petrov C2E 1.50 2048 b PCI-E 512 SATA 2 500 3 5 Ubuntu
Pronin C2E 2.00 2048 ext PCI-E 1024 SATA 5 1000 8 7 VISTA
Pavlow Athlon 3.20 4096 ext AGP 512 IDE 3 750 6 5 XP
Korsikov Celeron 1.50 512 ext AGP 128 IDE 1 120 3 4 XP
Savelyev C2E 3.20 4096 ext PCI-E 1024 SATA 4 950 7 6 XP
Sidorov Phenom 2.83 512 b AGP 256 IDE 2 350 4 4 VISTA
Potapov Celeron 3.00 512 ext AGP 128 IDE 1 120 1 4 XP
CPU2.txt, - CPU3.txt
out.txt, out2.txt out3.txt, : , , .
: cat out2.txt : No such file or directory. .
- , , .
: