Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- // o tabela de int-uri
- // o tabela de tabele de int-uri
- // numarul de elemente din fiecare vector
- // numarul de vectori
- typedef struct{
- int numar_de_vectori; // numarul de vectori
- int *lungime_individuala; // numarul de elemente din fiecare vector
- int **vectori; // o tabela de tabele de int-uri
- }TabelMare;
- #define MAX_LINE_LEN 10000
- int main() {
- // 3 4 2
- // 10 11
- // 4
- TabelMare tab;
- tab.numar_de_vectori = 3;
- tab.lungime_individuala = (int*)calloc(sizeof(int), tab.numar_de_vectori);
- tab.vectori = (int**)calloc(sizeof(int*), tab.numar_de_vectori);
- tab.lungime_individuala[0] = 3;
- tab.lungime_individuala[1] = 2;
- tab.lungime_individuala[2] = 1;
- for (int i = 0; i < tab.numar_de_vectori; ++i) {
- tab.vectori[i] = (int*)calloc(sizeof(int), tab.lungime_individuala[i]);
- }
- tab.vectori[0][0] = 3;
- tab.vectori[0][1] = 4;
- tab.vectori[0][2] = 2;
- tab.vectori[1][0] = 10;
- tab.vectori[1][1] = 11;
- tab.vectori[2][0] = 4;
- FILE *f = fopen("../in.txt", "r");
- if (f == NULL){
- return 1;
- }
- int ok=1;
- char*linie = (char*)calloc(sizeof(char ), MAX_LINE_LEN);
- while (ok){
- int rez_fgets = fgets(linie, MAX_LINE_LEN, f);
- if (rez_fgets == NULL || rez_fgets == EOF){
- break;
- }
- printf("-:%s", linie);
- }
- // for (int i = 0; i < tab.numar_de_vectori; ++i) {
- // for (int j = 0; j <tab.lungime_individuala[i]; ++j) {
- // printf("%d ", tab.vectori[i][j]);
- // }
- // printf("\n");
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement