Advertisement
Patey

Untitled

May 13th, 2021
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. void creare(char a[100])
  6. {
  7.     int i,actual=0,x;
  8.     char b[1];
  9.     for (i = 0; i < strlen(a); i++)
  10.     {
  11.         b[0] = a[i];
  12.         b[1] = '\0';
  13.         x = atoi(b);
  14.         while (actual < x)
  15.         {
  16.             actual++;
  17.             printf("(");
  18.         }
  19.         while (actual > x)
  20.         {
  21.             actual--;
  22.             printf(")");
  23.         }
  24.         printf("%d", x);
  25.  
  26.     }
  27.     while (actual > 0)
  28.     {
  29.         actual--;
  30.         printf(")");
  31.     }
  32. }
  33.  
  34. int main()
  35. {
  36.     int n,s[100],i;
  37.     printf("Dati nr de stringuri: ");
  38.     scanf("%d", &n);
  39.     for (i = 1; i <= n; i++)
  40.     {
  41.         printf("String nou:\n");
  42.         scanf("%s", s);
  43.         printf("\n\n");
  44.         creare(s);
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement