Patey

Untitled

Apr 16th, 2021
577
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4.  
  5. int nr_foldere, adancime[100][100], i, sum[100] = { 0 }, s = 0;
  6.  
  7. int generare(int j)
  8. {
  9.     if (j > adancime[i][0])
  10.         return adancime[i][j] = -1;
  11.     else
  12.     {
  13.         adancime[i][j] = rand() % 100;
  14.         return generare(j + 1);
  15.     }
  16. }
  17.  
  18. int main()
  19. {
  20.     int j;
  21.     srand(time(NULL));
  22.  
  23.     nr_foldere = rand() % 10 +1;
  24.     printf("%d\n\n", nr_foldere);
  25.  
  26.     for (i = 0; i < nr_foldere; i++)
  27.     {
  28.         adancime[i][0] = rand() % 5 +1;
  29.         j = 1;
  30.         generare(j);
  31.     }
  32.  
  33.     for (i = 0; i < nr_foldere; i++)
  34.     {
  35.         for (j = 0; j <= 5; j++)
  36.         {
  37.             if (adancime[i][j] == -1)
  38.                 break;
  39.             else
  40.             {
  41.                 printf("%d ", adancime[i][j]);
  42.                 if (j != 0)
  43.                 {
  44.                     sum[i] += adancime[i][j];
  45.                 }
  46.             }
  47.         }
  48.         printf("\n");
  49.     }
  50.     printf("\n");
  51.  
  52.     printf("Dimensiunea folderelor este:\n");
  53.     for (i = 0; i < nr_foldere; i++)
  54.     {
  55.         printf("%d ", sum[i]);
  56.         s += sum[i];
  57.     }
  58.  
  59.     printf("\nDimensiunea folderului este:\n");
  60.     printf("%d\n", s);
  61.  
  62. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×