Update a4/program.c
This commit is contained in:
		
							parent
							
								
									909a9286f8
								
							
						
					
					
						commit
						f27c6383c4
					
				
							
								
								
									
										23
									
								
								a4/program.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								a4/program.c
									
									
									
									
									
								
							@ -1,5 +1,23 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
///
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void print(int *a, int n, int index, int depth)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (index >= n)
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int i = 0; i < depth; i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        printf("  "); 
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    printf("%d\n", a[index]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    print(a, n, 2 * index + 1, depth + 1); 
 | 
				
			||||||
 | 
					    print(a, n, 2 * index + 2, depth + 1); 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main()
 | 
					int main()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int a[1000], i=0;
 | 
					    int a[1000], i=0;
 | 
				
			||||||
@ -28,11 +46,10 @@ int main()
 | 
				
			|||||||
    if(kupa)
 | 
					    if(kupa)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        printf("Je to taka kopa:\n");
 | 
					        printf("Je to taka kopa:\n");
 | 
				
			||||||
        printf("%d\n", a[0]);
 | 
					        print(a, n, 0, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        printf("Nie je kopa.\n");
 | 
					        printf("Nie je kopa.\n");
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user