Skip to main content

How to print top 3 hill from a list

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<stdio.h>
int main()
{
    int hight[10];
    int a,b,t;
    for(a=0;a<10;a++)//input 10 hill hight
        scanf("%d",&hight[a]);
    for(a=1;a<10;a++)
    {
        for(b=9;b>=a;b--)
        {
            if(hight[b-1]<hight[b])//putting big hight first
            {
                t=hight[b-1];
                hight[b-1]=hight[b];
                hight[b]=t;
            }
        }
    }
    for(t=0;t<3;t++)
        printf("%d\n",hight[t]);//print top three hill
    return 0;

}

Comments

Popular posts from this blog

  Good becomes great, bad becomes worse. A strong man who has known power all his life can lose respect for that power, but a weak man knows the value of strength and knows compression

Finding digit number of a number

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #include<stdio.h> int main() { long long int a,b, sum ,temp,count = 0 ,count_1 = 1 ; while ( (scanf( "%lld %lld" , & a, & b)) != EOF) { if (a <= 1000000 && b <= 1000000 ) { sum = a + b; temp = sum ; while (temp != 0 ) { sum /= 10 ; temp = sum ; count ++ ; } printf( "%lld \n " ,count); } count = 0 ; if (count_1 > 200 ) break ; count_1 ++ ; } return 0 ; }