Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int main(int argc, char **argv)
- {
- FILE *fp;
- int a;
- float s;
- int a5=0, a6=0, a7=0, a8=0, a9=0, a10=0;
- fp=fopen("ispit.dat", "r");
- if (fp==NULL) return 0;
- else {
- printf("Otvorena!\n");
- while(!feof(fp)) {
- if (isdigit(getc(fp))) {
- fseek(fp, -1, 1);
- fscanf(fp, "%d", &a);
- if (a<51) a5++;
- else if (a>50 && a<61) a6++;
- else if (a>60 && a<71) a7++;
- else if (a>70 && a<81) a8++;
- else if (a>80 && a<91) a9++;
- else if (a>90 && a<101) a10++;
- else {
- printf("Nedozvoljen broj bodova!\n");
- fclose(fp);
- return 0;
- }
- }
- }
- fclose(fp);
- printf("Zatvorena!\n");
- }
- fp=fopen("analiza.txt", "w");
- if (fp==NULL) return 0;
- else {
- printf("Otvorena!\n");
- s=a5+a6+a7+a8+a9+a10;
- fprintf(fp, "Izvanredan (>90): %dx (%5.2f%%)\n", a10, (a10)/s*100);
- fprintf(fp, "Odlican (81-90): %dx (%5.2f%%)\n", a9, (a9/s)*100);
- fprintf(fp, "Vrlodobar (71-80): %dx (%5.2f%%)\n", a8, (a8/s)*100);
- fprintf(fp, "Dobar (61-70): %dx (%5.2f%%)\n", a7, (a7/s)*100);
- fprintf(fp, "Dovoljan (51-60): %dx (%5.2f%%)\n", a6, (a6/s)*100);
- fprintf(fp, "Nedovoljan (<51): %dx (%5.2f%%)\n", a5, (a5/s)*100);
- }
- fclose(fp);
- printf("Zatvorena!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement