Sh3ll
OdayForums


Server : Apache
System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64
User : apache ( 48)
PHP Version : 8.0.28
Disable Function : NONE
Directory :  /var/www/html/bibhas.ghoshal/Data_Structures_2022/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/bibhas.ghoshal/Data_Structures_2022/tournament.c
//
//  tournament.c
//  
//
//  Created by Bibhas Ghoshal on 04/06/22.
//

#include <stdio.h>

int main()
{
    int tourn[100],i,n;
    
    /* Read N */
    
    printf("Give n:");
    scanf("%d",&n);
    printf("\n n = %d \n",n);
    
    for(i=n; i<=2*n-1; i++){
        scanf("%d",&tourn[i]);
    }
    /* Compute the tournament */
        
    for(i=2*n-2;i>1; i=i-2){
        tourn[i/2] = maxi(tourn[i],tourn[i+1]);
    }
        /* Print Result */
        
    for(i=1; i<=2*n-1; i++){
        printf("%d",tourn[i]);
        printf("\n");}  
    
}
    
int maxi(int i ,int j)
{
    if(i>j) return(i);
    else return(j);
}

ZeroDay Forums Mini