Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tema Lab 7
- //Pr1
- #include <stdio.h>
- #include <conio.h>
- int main ()
- {
- FILE *fin;
- char s[30];
- int primul,x,nr=0,total=1;
- printf("Introdu numele fisierului: ");
- scanf("%s", &s);
- fin=fopen(s, "rt");
- if(!fin)
- {
- printf("Eroare la deschidere");
- getch();
- return 1;
- }
- fscanf(fin, "%i", &primul);
- while(!feof(fin))
- {
- fscanf(fin, "%i ", &x);
- total++;
- if(x>primul)
- nr++;
- }
- printf("%4.2f", (float)nr/total*100);
- getch();
- return 0;
- }
- //Pr2
- #include <stdio.h>
- #include <conio.h>
- int main ()
- {
- FILE *fin;
- char s[50];
- int nrs=0, i=0, maxs=0, max=1, nos=0;
- printf("Introdu numele fisierului: ");
- scanf("%s", &s);
- fin=fopen(s, "rt");
- if(!fin)
- {
- printf("Eroare la deschidere");
- getch();
- return 1;
- }
- while(!feof(fin))
- {
- nrs=0;
- char *p;
- i++;
- fgets(s, 50, fin);
- for(p=s;*p;p++)
- if(*p==' ')
- nrs++;
- if(nrs>maxs)
- max=i;
- else if(nrs==0 && s[0]!='\n')
- nos++;
- }
- printf("Procent: %.2f\tIndice linie: %i", (float)nos/i*100, max);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment