Professional Documents
Culture Documents
info2021
info2021
#include <stdio.h>
int perrin(int n)
{
if(n==0){ return 3;}
if(n==1){return 0;}
if(n==2){return 2;}
int ex2(int n)
{int i, s=0;
for(i=1;i<=n;i++)
{
s+=i;
}
return s;
int main()
{
printf("%d",ex2(4));
return 0;
}
exercise3:
#include <stdio.h>
int ID;
char name[20];
float price;
}article;
return k;
f=fopen("DATA.txt","r");
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
while(!feof(f))
{
if(ID==c.ID){ break; }
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
}
fclose(f);
f=fopen("DATA.txt","r");
max.price=c.price;
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
while(!feof(f))
{
}
fclose(f);
return max;
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
while(!feof(f))
{
}fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
fclose(f);
fclose(t);
f=fopen("DATA.txt","w");
t=fopen("temp.txt","r");
fscanf(t,"%d%s%f",&c.ID,c.name,&c.price);
while(!feof(t))
{
fprintf(f,"%d %s %f",c.ID, c.name, c.price );
fscanf(t,"%d%s%f",&c.ID,c.name,&c.price);
}
fclose(f);
fclose(t);
}
void clean()
{
FILE *f;
article c;
f=fopen("DATA.txt","r");
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
while(!feof(f))
{
delet(c.ID);
fscanf(f,"%d%s%f",&c.ID,c.name,&c.price);
}
int main()
{
return 0;
}