Advertisement
DmitryPythonDevelop

lab4

Oct 13th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.    
  6.     int i=0, max_i=0, s;
  7.     //char s;
  8.    
  9.     printf("Введите код:\n\n");
  10.    
  11.     while((s=getchar())!=EOF) {
  12.        
  13.         printf("%d", s);
  14.        
  15.         if(s=='{'){
  16.             i=i+1;
  17.            
  18.             if(max_i<i){
  19.                 max_i=i;
  20.             }
  21.         }
  22.         if(s=='}'){
  23.                 i=i-1;
  24.         }
  25.        
  26.     }
  27.        
  28.     printf("Максимальный уровень вложенности фигурных скобок - %d", max_i);
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement