Vous êtes sur la page 1sur 18

#include <stdio.

h>
#include <stdlib.h>
char get_byte(int poz, FILE *pFile)
{
char byte;
fseek(pFile, poz, 0);
fread(&byte, 1, 1, pFile);
return byte;
}
int get_int(int poz, FILE *pFile)
{
int x;
fseek(pFile, poz, 0);
fread(&x, 4, 1, pFile);
return x;
}
int get_dimension_of_file(FILE *pFile)
{
int size;
fseek(pFile, 0, 2);
/* file pointer at the end of file */
size = ftell(pFile);
return size;
}
int check_partition(int poz, int cu_afisare, FILE *pFile)
{
if(!poz)
return 1; //nu stiu ce se intamla daca gaseste o partitie stearsa (adica
in mbr sa gasesc 4 de 0 consecutivi ca adresa)
//pe langa faptul ca verifica partitia, poate afisa si schema ei.
int MAXD, MAXF, total_space, bytes_used, i,j,k;
int name_length;
if(cu_afisare)
{
for(i=poz+4; i<poz+12; i++)
{
printf("%c", get_byte(i, pFile));
}
}
MAXD = get_int(poz+12, pFile);
MAXF = get_int(poz+16, pFile);
total_space = MAXD*MAXF*12 + MAXD*12 + MAXF*12;
bytes_used = total_space; //vom scada cand gasim dir/fis goale.

//printf("%d %d %d\n", poz, MAXD, MAXF);


poz =poz+20;
for(i=1; i<=MAXD; i++)
{
name_length = get_int(poz, pFile);
if(name_length>8)
{
return 0;
}
if(!name_length)
{

//bytes_used-=(12*(MAXF+1)); //SCAD DEAODATA TOT FIS


bytes_used-=(12);
}
//printf(" %d", name_length);
poz=poz+4;
for(j=poz; j<poz+8; j++)
{
//printf("%c", get_byte(j, pFile));
}
poz=poz+8;
// printf("\n");
for(j=1; j<=MAXF; j++)
{
// printf("
");
name_length = get_int(poz, pFile);
if(name_length>8)
return 0;
if(!name_length)
{
bytes_used-=(12);
}
poz=poz+4;
for(k=poz; k<poz+8; k++)
{
//printf("%c", get_byte(k, pFile));
}
poz=poz+8;
//printf(" ");
}
//printf("\n");
}
for(j=1; j<=MAXF; j++)
{
//printf("
");
name_length = get_int(poz, pFile);
if(name_length>8)
return 0;
if(!name_length)
{
bytes_used-=(12);
}
poz=poz+4;
for(k=poz; k<poz+8; k++)
{
//printf("%c", get_byte(k, pFile));
}
poz=poz+8;
}
//printf("\n");

/*for(i=poz+24; i<=poz+31; i++)


{
printf("%c", get_byte(i, pFile));
}
printf("\n");*/
if(cu_afisare)

{
printf(" %d %d\n", total_space, bytes_used);
}
return 1;
}
int find_director(char target_partition_name[100], char target_director_name[100
], int *MAXD, int *MAXF, int *poz_partition)
{
/*returneaza pozitiade inceput a directorului, incepand cu headerul*/
/*avem si var poz_partition, deoarece cand cautam un fisier, cu aceasta fct
e posibil sa nu fie specificat un director, si sa avem nevoie doar de incepu
tul partitiei*/
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb" );
int i, ct, nb_partitions, k, poz, j, name_length, k1, k2;
char name_of_partition[10], name_of_director[10];
nb_partitions = get_int(0, pFile);
for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
//verificam daca exista partitia din path
poz = get_int(k, pFile);
name_length=get_int(poz, pFile);
for(j=poz+4, ct=0; j<poz+4+name_length; j++)
{
name_of_partition[ct++]=get_byte(j, pFile);
}
name_of_partition[ct]='\0';
if(!strcmp(target_partition_name, name_of_partition))
{
//printf("\ngasit partitie\n");
//verificam daca exsita si directorul din path
if(poz_partition!=NULL)
*poz_partition = poz;
(*MAXD) = get_int(poz+12, pFile);
(*MAXF) = get_int(poz+16, pFile);
poz+=20;
for(k1=1; k1<=(*MAXD); k1++)
{
name_length=get_int(poz, pFile);
for(k2 = poz+4, ct=0; k2<poz+4+name_length; k2++)
{
name_of_director[ct++]=get_byte(k2, pFile);
}
name_of_director[ct]='\0';
if(!strcmp(target_director_name, name_of_director))
{
return poz;
}
else
{
poz+=4+8+12*(*MAXF);

}
}
}
}
fclose(pFile);
return 0;
}

void extract_info_from_path(char path[100], char name_of_file[100], char name_of


_director[100], char name_of_partition[100], int *in_director)
{
//trebie sa stabilim daca fisierul va fi creat intr-un director sau in afara
directoarelor pe partitie
//in_director ne ve indica daca va tb sa cautam in director sau nu. 1 pt da,
0 pt nu
int i, ct=0, dim;
int l = strlen(path);
//printf("lungime path %d\n", l);
for(i=0; i<=7; i++)
{
name_of_partition[i]=path[i];
}
name_of_partition[8]='\0';
for(i=0; i<l; i++)
{
if(path[i]=='/')
{
ct++;
}
}
//daca path are 3 caractere / atunci cautam spatiu in afara directoarelor. d
aca are 4 cautam intr-un director
if(ct==3)
{
(*in_director) = 0;
dim=-1; //reconstituim numele fisierului
for(i=9; i<l; i++)
{
dim++;
name_of_file[dim]=path[i];
name_of_file[dim+1]='\0';
}
}
else
{
(*in_director) = 1;
ct=9; dim=-1; //reconstituim numele dirctorului
while(path[ct]!='/')
{
dim++;
name_of_director[dim]=path[ct];
name_of_director[dim+1]='\0';
ct++;
}
ct++;

dim=-1; //reconstituim numele fisierului


for(i=ct; i<l; i++)
{
dim++;
name_of_file[dim]=path[i];
name_of_file[dim+1]='\0';
}
}
}
void CREATE_FILE(char path[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
char name_of_director[100], name_of_file[100], name_of_partition[100];
int sir[100]={0};
int poz, MAXD, MAXF;
int in_director, i, name_dim;
int valid=0, partition_start;
extract_info_from_path(path, name_of_file, name_of_director, name_of_partiti
on, &in_director);
poz = find_director(name_of_partition, name_of_director, &MAXD, &MAXF, &part
ition_start);
//printf(" %d", partition_start);
if(in_director)
{
if(poz)
{
for(i=1; i<=MAXF; i++)
{
poz+=12;
fseek(pFile, poz, SEEK_SET );
name_dim = get_int(poz, pFile);
if(!name_dim)
{
//am gasit un spatiu gol
valid=1;
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(name_of_file);
fwrite( sir, 4, 1, pFile );
fwrite( name_of_file, 1, sir[0], pFile );
}
}
}
}
else
{
//cazul in care e in afara partitiei
if(poz)
{
poz = partition_start + 20 + MAXD * (12 + 12*MAXF);
fseek(pFile, poz, SEEK_SET );
for(i=1; i<=MAXF; i++)
{
fseek(pFile, poz, SEEK_SET );
name_dim = get_int(poz, pFile);

if(!name_dim)
{
//am gasit un spatiu gol
valid=1;
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(name_of_file);
fwrite( sir, 4, 1, pFile );
fwrite( name_of_file, 1, sir[0], pFile );
}
poz+=12;
}
}
}
if(!valid)
{
printf("INVALID\n");
}
else
{
printf("SUCCES\n");
}
fclose(pFile);
}
void RENAME_FILE(char path[100], char new_name[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
char name_of_director[100], name_of_file[100], name_of_partition[100];
int sir[100]={0};
int poz, MAXD, MAXF;
int in_director, i, name_dim;
int valid=0, partition_start;
extract_info_from_path(path, name_of_file, name_of_director, name_of_partiti
on, &in_director);
poz = find_director(name_of_partition, name_of_director, &MAXD, &MAXF, &part
ition_start);
char name[100]; //variabila in care tinem minte numele fisierelor gasite pe
partitie;

if(in_director)
{
if(poz)
{
for(i=1; i<=MAXF; i++)
{
poz+=12;
fseek(pFile, poz, SEEK_SET );
name_dim = get_int(poz, pFile);
fread(name, 1, name_dim, pFile);
name[name_dim]='\0';
if(!strcmp(name, name_of_file))
{

//am gasit fisierul cu numele name_of_file si tb sa il schim


bam
valid=1;
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(new_name);
fwrite( sir, 4, 1, pFile );
fwrite( new_name, 1, sir[0], pFile );
}
}
}
}
else
{
if(poz)
{
poz = partition_start + 20 + MAXD * (12 + 12*MAXF);
fseek(pFile, poz, SEEK_SET );
for(i=1; i<=MAXF; i++)
{
fseek(pFile, poz, SEEK_SET );
name_dim = get_int(poz, pFile);
fread(name, 1, name_dim, pFile);
name[name_dim]='\0';
if(!strcmp(name, name_of_file))
{
//am gasit fisierul cu numele name_of_file si tb sa il schim
bam
valid=1;
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(new_name);
fwrite( sir, 4, 1, pFile );
fwrite( new_name, 1, sir[0], pFile );
}
poz+=12;
}
}
}
if(!valid)
{
printf("INVALID\n");
}
else
{
printf("SUCCES\n");
}

fclose(pFile);
}

void PRINT(char path[100])


{
//din primele 8 carct fac numele partitiei, apoi din restu nr directt
//si caut directorul. daca nu gasesc atunci invalid
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb" );
int i, l,poz, name_length, k1, k2;
int valid=0;
int MAXD, MAXF;
char partitie[10], nume_dir[10];
l=strlen(path);
for(i=0; i<=7; i++)
{
partitie[i]=path[i];
}
partitie[8]='\0';
for(i=9; i<l; i++) //sarim peste caracterul '/' care urm dupa numele partiti
ei
{
nume_dir[i-9]=path[i];
}
nume_dir[l-9]='\0';
//printf("\n%s %s\n", partitie, nume_dir);
poz = find_director(partitie, nume_dir, &MAXD, &MAXF, NULL);
//printf(" %d", poz);
if(poz)
{
poz+=12;
valid=1;
for(k1=1; k1<=MAXF; k1++)
{
name_length = get_int(poz, pFile);
//daca nu gaseste niciun fisier ramane invalid?!
if(name_length!=0)
{
valid=1;
poz=poz+4;
for(k2=poz; k2<poz+name_length; k2++)
{
printf("%c", get_byte(k2, pFile));
}
poz=poz+8;
printf("\n");
}
}
}
/*if(!valid2)
printf("\n"); //pt cazu in care gaseste dir goale*/
if(!valid)
{
printf("INVALID\n");

}
fclose(pFile);
}
void RENAME_DIR(char path[100], char new_name[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
int i, l, poz;
int MAXD, MAXF;
int sir[1000]={0};
char partition_name[10], director_name[10];
l=strlen(path);
for(i=0; i<=7; i++)
{
partition_name[i]=path[i];
}
partition_name[8]='\0';
for(i=9; i<l; i++) //sarim peste caracterul '/' care urm dupa numele partiti
ei
{
director_name[i-9]=path[i];
}
director_name[l-9]='\0';
//printf("\n%s %s\n", partitie, nume_dir);
poz = find_director(partition_name, director_name, &MAXD, &MAXF, NULL);
if(poz)
{
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(new_name);
fwrite( sir, 4, 1, pFile );
poz+=4;
fwrite( new_name, 1, sir[0], pFile );
printf("SUCCES\n");
}
else
{
printf("INVALID\n");
}
fclose(pFile);
/*verificare temp
pFile = fopen ( "mbr.bin" , "rb+" );
poz = find_director(partition_name, director_name, &MAXD, &MAXF);
printf("%d", poz);*/
}
void DELETE_DIR(char path[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
int i, l, poz;
int MAXD, MAXF;
int sir[1000]={0};
char partition_name[10], director_name[10];
l=strlen(path);

for(i=0; i<=7; i++)


{
partition_name[i]=path[i];
}
partition_name[8]='\0';
for(i=9; i<l; i++) //sarim peste caracterul '/' care urm dupa numele partiti
ei
{
director_name[i-9]=path[i];
}
director_name[l-9]='\0';
//printf("\n%s %s\n", partitie, nume_dir);
poz = find_director(partition_name, director_name, &MAXD, &MAXF, NULL);
if(poz)
{
//marcam bytii care cuprind dim numelui si numele cu 0
fseek(pFile, poz, SEEK_SET );
sir[0]=0;
fwrite( sir, 1, 12, pFile );
//tb sa stergem si fisierele din el
fwrite( sir, 1, 12*MAXF, pFile );
printf("SUCCES\n");
}
else
{
printf("INVALID\n");
}
fclose(pFile);

}
void CREATE_DIR(char path[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
int i, l, ct, nb_partitions, k, poz, j, name_length, k1;
int valid=0;
int MAXD, MAXF;
int sir[1000]={0};
char partition_name[10], director_name[10], name_of_partition[10];
l=strlen(path);
for(i=0; i<=7; i++)
{
partition_name[i]=path[i];
}
partition_name[8]='\0';
for(i=9; i<l; i++) //sarim peste caracterul '/' care urm dupa numele partiti
ei
{
director_name[i-9]=path[i];
}
director_name[l-9]='\0';
//printf("\n%s %s\n", partitie, nume_dir);

//cautam un director cu numele de 0 cracrtere, doearece asta


//inseamna ca e un director sters, deci avem spatiu pt unu nou
//mai intai vedem daca nu cumva exista deja
//ar tb sa vedem cate directoare si cate poate avea maxim.
poz = find_director(partition_name, director_name, &MAXD, &MAXF, NULL);
if(!poz)
{
nb_partitions = get_int(0, pFile);
for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
//verificam daca exista partitia din path
poz = get_int(k, pFile);
name_length=get_int(poz, pFile);
for(j=poz+4, ct=0; j<poz+4+name_length; j++)
{
name_of_partition[ct++]=get_byte(j, pFile);
}
name_of_partition[ct]='\0';
if(!strcmp(partition_name, name_of_partition))
{
//printf("\ngasit partitie\n");
//verificam daca exsita si directorul din path
MAXD = get_int(poz+12, pFile);
MAXF = get_int(poz+16, pFile);
poz+=20;
for(k1=1; k1<=MAXD; k1++)
{
name_length=get_int(poz, pFile);
if((!name_length) && (!valid))
{
//AM GASIT SPATIU PENTRU DIRECTOR!!
fseek(pFile, poz, SEEK_SET );
sir[0]=strlen(director_name);
fwrite( sir, 4, 1, pFile );
poz+=4;
fwrite( director_name, 1, sir[0], pFile );
printf("SUCCES\n");
valid=1;
}
else
{
poz+=4+8+12*MAXF;
}
}
}
}
}
if(!valid)
{
printf("INVALID\n");
}
fclose(pFile);
}

void task1()
{
int i, k;
int nb_partitions, valid;
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb" );
valid = 1;
// printf("%d", get_dimension_of_file(pFile));
nb_partitions = get_int(0, pFile);
for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
if(!check_partition(get_int(k, pFile), 0, pFile))
{
printf("INVALID\n");
valid = 0;
break;
}
}
if(valid)
{
printf("SUCCES\n");
for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
check_partition(get_int(k, pFile), 1, pFile);
}
}
/*for(i=0; i<=get_dimension_of_file(pFile); i++)
{
printf("%d ", get_byte(i, pFile));
}*/
}
void task2()
{
char command[100], path[100], name[100];
FILE *pFile;
pFile = fopen ( "mbr.op" , "r" );
while(1)
{
strcpy(command, "blank");
fscanf(pFile, "%s", command);
if(!strcmp(command, "CREATE_FILE"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
//printf("\n%s\n", path);
CREATE_FILE(path);
continue; //CHECKED
}
if(!strcmp(command, "RENAME_FILE"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
fscanf(pFile, "%s", name);
// printf("\n%s", path);
// printf(" %s\n", name);
RENAME_FILE(path, name);

continue; //CHECKED
}
if(!strcmp(command, "DELETE_FILE"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
//printf("\n%s\n", path);
RENAME_FILE(path, "");
continue; //CHECKED
}
if(!strcmp(command, "CREATE_DIR"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
//printf(" %s\n", path);
CREATE_DIR(path);
continue; //CHECKED
}
if(!strcmp(command, "RENAME_DIR"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
fscanf(pFile, "%s", name);
//printf("\n%s", path);
//printf(" %s\n", name);
RENAME_DIR(path, name); //CHECKED
continue;
}
if(!strcmp(command, "DELETE_DIR"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
//printf(" %s\n", path);
DELETE_DIR(path);
continue; //CHECKED
}
if(!strcmp(command, "PRINT"))
{
//printf("%s", command);
fscanf(pFile, "%s", path);
//printf(" %s\n", path);
PRINT(path);
continue; //CHECKED
}
if(!strcmp(command, "blank"))
{
//printf("%s\n", command);
break; //CHECKED
}
}
}
void DELETE_PARTITION(char target_partition_name[100])
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
int i,ct, nb_partitions, k, poz, j, name_length;
int valid=0;
int zero=0;
char name_of_partition[10];

nb_partitions = get_int(0, pFile);


for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
poz = get_int(k, pFile);
name_length=get_int(poz, pFile);
for(j=poz+4, ct=0; j<poz+4+name_length; j++)
{
name_of_partition[ct++]=get_byte(j, pFile);
}
name_of_partition[ct]='\0';
if(!strcmp(target_partition_name, name_of_partition))
{
//remove partition
valid=1;
nb_partitions--;
fseek(pFile, k, SEEK_SET );
fwrite(&zero, 4, 1, pFile);
fseek(pFile, 0, SEEK_SET );
//fwrite(&nb_partitions, 4, 1, pFile); ?
fseek(pFile, k, SEEK_SET );

}
}
fclose(pFile);
if(!valid)
{
printf("INVALID\n");
}
else
{
printf("SUCCES\n");
}

}
void FORMAT_PARTITION(char partition_name[100])
{
FILE *pFile;
pFile = fopen ( "mbr.op" , "rb+" );
int MAXD, MAXF, poz=0;
int zero[1000]={0};
int formula;
char random_dir_name[100];//ne intereseaza sa gaseasca doar paritita, asa
//ca dau un nume random pt parametrul director
strcpy(random_dir_name, "ceva_random");
find_director(partition_name, random_dir_name, &MAXD, &MAXF, &poz); //gasest
e inceputul partitiei
if(poz)
{
fseek(pFile, poz+20, SEEK_SET );
formula = MAXD*(12+12*MAXF)+12*MAXF; //nr divizibil mereucu 4;

printf("SUCCES\n");
fwrite(zero, 4, formula/4, pFile);
}
else
{
printf("INVALID\n");
}

}
void CREATE_PARTITION(char partition_name[100], int MAXD, int MAXF)
{
int MAXDP, MAXFP;
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
int lista_adrese[1000], k, i, poz, next_space;
lista_adrese[0]=0;
int liber=0;
int nb_partitions = get_int(0, pFile);
int valid=0, dim, space_needed;
for(i=1, k=4; i<=nb_partitions; i++, k+=4)
{
poz = get_int(k, pFile);
if(poz)
{
lista_adrese[0]++;
lista_adrese[lista_adrese[0]]=poz;
}
else
{
if(!liber)
{
liber=k; //retinem poztia primului spatiu gol din mbr.
}
}
}
//printf("Adresele sunt : ");
for(i=1; i<=lista_adrese[0]; i++)
{
//eventual le sortez crescator
//printf("%d ", lista_adrese[i]);
}
//se garanteaza ca nu se sterge prima partitie. presuspun ca adresa primei e
imediar dupa mbr
//asa ca nu mai verific daca e spatiu intre mbr si restu
if(!liber)
{
//nu mai e loc in mbr!!
}
for(i=1; i<lista_adrese[0]; i++)
{
poz=lista_adrese[i];
//verificam spatiul intre 2 partitii. daca e destul cream o partitie nou
a
fseek(pFile, poz, SEEK_SET );

MAXDP = get_int(poz+12, pFile);


MAXFP = get_int(poz+16, pFile);
// printf("%d %d\n", MAXDP, MAXFP);
next_space = poz + 20 + MAXDP*(12+12*MAXFP)+12*MAXFP;
//printf("next space is: %d\n", next_space);
space_needed = 20 + MAXD*(12+12*MAXF)+12*MAXF;
if(lista_adrese[i+1]-next_space >=space_needed)
{
valid=1;
fseek(pFile, liber, SEEK_SET );
//printf("liber: %d", liber);
fwrite(&next_space, 4, 1, pFile);
fseek(pFile, next_space, SEEK_SET );
dim=strlen(partition_name);
fwrite(&dim, 4, 1, pFile);
fwrite(partition_name, 1, dim, pFile);
fwrite(&MAXD, 4, 1, pFile);
fwrite(&MAXF, 4, 1, pFile);
break;
}
}
if(!valid)
{
printf("INVALID\n");
}
else
{
printf("%d\n", next_space);
}
}
void task3()
{
char command[100], name[100];
int MAXD, MAXF;
FILE *pFile;
pFile = fopen ( "mbr.op" , "r" );
while(1)
{
strcpy(command, "blank");
fscanf(pFile, "%s", command);
if(!strcmp(command, "DELETE_PARTITION"))
{
fscanf(pFile, "%s", name);
DELETE_PARTITION(name);
}
if(!strcmp(command, "FORMAT_PARTITION"))
{
fscanf(pFile, "%s", name);
FORMAT_PARTITION(name);
}
if(!strcmp(command, "CREATE_PARTITION"))
{
fscanf(pFile, "%s%d%d", name, &MAXD,&MAXF);
CREATE_PARTITION(name, MAXD, MAXF);

}
if(!strcmp(command, "blank"))
{
//printf("%s\n", command);
break; //CHECKED
}
}
fclose(pFile);

}
void bonus()
{
FILE *pFile;
pFile = fopen ( "mbr.bin" , "rb+" );
char name[100], pattern[100];
int dim = get_dimension_of_file(pFile);
int mbr[100], i;
mbr[0]=0;
strcpy(pattern, "/dev/sd" );
for(i=1; i<dim-8; i++)
{
fseek(pFile, i, SEEK_SET );
fread(name, 1, 7, pFile);
if(!strcmp(name, pattern))
{
mbr[0]++;
mbr[mbr[0]]=i-4;
}
}
printf("MBR_SIZE: %d\n", mbr[0]);
printf("PARTITIONS_OFFSET:");
for(i=1; i<=mbr[0]; i++)
{
printf(" %d", mbr[i]);
}
fclose(pFile);
}
main(int argc, char *argv[])
{
FILE *pFile;
pFile = fopen ( "stefan.out" , "a" );
//scanf("%d", &opt);
fprintf(pFile, "%s\n", argv[1]);
/*switch(opt)
{
case 1:
task1();
break;
case 2:
task2();
break;

case 3:
task3();
break;
case 4:
bonus();
break;
default:
break;
}*/
int bonuss=1;
if(!strcmp(argv[1], "1"))
{
task1();
bonuss=0;
}
if(!strcmp(argv[1], "2"))
{
bonuss=0;
task2();
}
if(!strcmp(argv[1], "3"))
{
bonuss=0;
task3();
}
if(bonuss)
bonus();

return 0;
}

Vous aimerez peut-être aussi