[sourcecode language="c"]
//Author: Md. Rana Mahmud
#include <stdio.h>
void insertionSort(int a[],int length)
{
int key,i,j;
for(j = 1; j<length; j++)
{
key = a[j];
i = j-1;
while(i>=0&&a[i]>key)
{
a[i+1] = a[i];
i--;
}
a[i+1] = key;
}
}
int main()
{
int data[1000],i,num;
printf("Enter how many numbers are there : \n");
scanf("%d",&num);
printf("Enter the numbers: \n");
for(i = 0; i<num; i++)
scanf("%d",&data[i]);
insertionSort(data,num);
printf("The sorted numbers are : \n");
for(i = 0; i<num; i++)
printf("%d ",data[i]);
printf("\n");
return 0;
}
[/sourcecode]
শনিবার, ২৪ অক্টোবর, ২০১৫
শুক্রবার, ২৩ অক্টোবর, ২০১৫
URI Online Judge | 1943 Top N Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Md. Rana Mahmud | |
#include <stdio.h> | |
int main(){ | |
int k; | |
scanf("%d",&k); | |
printf("Top "); | |
if(k==1) | |
printf("1\n"); | |
else if(k>1&&k<=3) | |
printf("3\n"); | |
else if(k>3&&k<=5) | |
printf("5\n"); | |
else if(k>5&&k<=10) | |
printf("10\n"); | |
else if(k>10&&k<=25) | |
printf("25\n"); | |
else if(k>25&&k<=50) | |
printf("50\n"); | |
else if(k>50&&k<=100) | |
printf("100\n"); | |
return 0; | |
} |
লেবেলসমূহ:
URI Online Judge Solution
মঙ্গলবার, ২০ অক্টোবর, ২০১৫
এতে সদস্যতা:
পোস্টগুলি (Atom)