#91
Masini
În curtea unui atelier de reparaţii auto, sunt n
maşini care trebuie sa fie reparate. Deoarece nu sunt suficienţi mecanici, în fiecare moment de timp se poate lucra doar la o singură maşină.
Cunoscând timpul necesar pentru repararea fiecărei maşini, scrieţi un program care calculează numărul maxim de maşini care pot fi reparate într-un interval de timp T
.
Problema | Masini | Operații I/O |
![]() masini.in /masini.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #51219611 | Utilizator | |
Fișier | masini.c | Dimensiune | 561 B |
Data încărcării | 30 Mai 2024, 16:32 | Scor / rezultat | Eroare de compilare |
masini.c:4:1: warning: data definition has no type or storage class [enabled by default] f=fopen("masini.in", r); ^ masini.c:4:1: warning: type defaults to 'int' in declaration of 'f' [enabled by default] masini.c:4:1: error: conflicting types for 'f' masini.c:3:7: note: previous declaration of 'f' was here FILE* f, g; ^ masini.c:4:22: error: 'r' undeclared here (not in a function) f=fopen("masini.in", r); ^ masini.c:5:1: warning: data definition has no type or storage class [enabled by default] g=fopen("masini.out", w); ^ masini.c:5:1: warning: type defaults to 'int' in declaration of 'g' [enabled by default] masini.c:5:1: error: conflicting types for 'g' masini.c:3:10: note: previous declaration of 'g' was here FILE* f, g; ^ masini.c:5:23: error: 'w' undeclared here (not in a function) g=fopen("masini.out", w); ^ masini.c: In function 'main': masini.c:9:5: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &n, &T); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from masini.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * restrict' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ masini.c:9:5: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &n, &T); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from masini.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * restrict' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ masini.c:11:9: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", &a[i]); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from masini.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * restrict' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ masini.c:11:9: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", &a[i]); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from masini.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * restrict' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ masini.c:11:9: warning: format not a string literal and no format arguments [-Wformat-security] fscanf("%d", &a[i]); ^ masini.c:16:21: warning: assignment makes integer from pointer without a cast [enabled by default] aux = a+1; ^ masini.c:17:21: error: lvalue required as left operand of assignment a+1 = a + n + 1; ^ masini.c:18:27: error: lvalue required as left operand of assignment a + n + 1 = aux; ^ masini.c:22:5: warning: passing argument 1 of 'fprintf' from incompatible pointer type [enabled by default] fprintf("%d", j); ^ In file included from /usr/include/stdio.h:937:0, from masini.c:1: /usr/include/i386-linux-gnu/bits/stdio2.h:95:1: note: expected 'struct FILE * restrict' but argument is of type 'char *' fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) ^ masini.c:22:5: warning: passing argument 2 of 'fprintf' makes pointer from integer without a cast [enabled by default] fprintf("%d", j); ^ In file included from /usr/include/stdio.h:937:0, from masini.c:1: /usr/include/i386-linux-gnu/bits/stdio2.h:95:1: note: expected 'const char * restrict' but argument is of type 'int' fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) ^ masini.c:22:5: warning: format not a string literal and no format arguments [-Wformat-security] fprintf("%d", j); ^ masini.c:9:11: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf("%d%d", &n, &T); ^ masini.c:11:15: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf("%d", &a[i]); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Masini face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.