Skip to content

Instantly share code, notes, and snippets.

@setanjan123
Created December 19, 2017 13:20
Show Gist options
  • Save setanjan123/9445b3fa8ad4162bc52c9d095f6aa6a5 to your computer and use it in GitHub Desktop.
Save setanjan123/9445b3fa8ad4162bc52c9d095f6aa6a5 to your computer and use it in GitHub Desktop.
#include<stdio.h>
int main()
{
int arr[]={3,1,2,4,6,9,8,5,7};
int arr2[9];
int k=4,i,j,temp,l=0;
for(i=0;i<9;i++)
{
for(j=0;j<9-i;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(i=0;i<4;i++)
arr2[i]=arr[i];
for(i=4,j=8;j>=4,i<9;j--,i++)
arr2[i]=arr[j];
for(i=0;i<9;i++)
printf("%d",arr2[i]);
return 0;
}
#include<stdio.h>
int main()
{
int i,j=1,k,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
k=i;
while(k>1)
{
printf("%d*",j);
j++;
k--;
}
printf("%d\n",j);
j++;
}
j--;
for(i=n;i>=1;i--)
{
k=i;
while(k>1)
{
printf("%d*",j);
j--;
k--;
}
printf("%d\n",j);
j--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment