Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMAN_GUPTA29 #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions matrix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include<stdio.h>
#include<stdlib.h>
#include<math.h>



int b;

int creatematrix(int a)
{
printf("enter elements\n");
int array[a][b];
for(int i=0;i<a;i++)
{
int j;
for(j=0;j<b;j++)
{
int key1;
scanf("%d",&key1);
array[i][j]=key1;
}
}
presentmatrix(array,a);
}


int presentmatrix(int array[][b],int a)
{

int i,j;
for( i=0;i<a;i++)
{

for(j=0;j<b;j++)
{
int key=array[i][j];

printf("%d ",key);

}
printf("\n");
}


}



void main()
{
int a;
printf("enter the dimansion of matrix\n");
scanf("%d",&a);

scanf("%d",&b);

creatematrix(a);
}
116 changes: 116 additions & 0 deletions radixsort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include<stdio.h>
#include<math.h>

int radixsort(int arr[], int size,int length)
{
int range=10;
int lcount=0;
int ray=size;
int outputarray[ray];
for(int k=0;k<length;k++)
{
int indexarr[range];
int cumalativesum[range];
for(int i=0;i<range;i++)
{
indexarr[i]=0;
cumalativesum[i]=0;
}

for(int i=0;i<size;i++)
{
int value=arr[i];
int digit=value/(pow(10,lcount));
int dig=digit%10;
indexarr[dig]=indexarr[dig]+1;
}



for(int i=0;i<range;i++)
{
cumalativesum[i]=cumalativesum[i-1]+indexarr[i];
}




for(int i=ray-1;i>=0;i--)
{
int key=arr[i];
int digit2=key/(pow(10,lcount));
int dig2=digit2%10;
int findex=cumalativesum[dig2];
outputarray[findex-1]=key;
--cumalativesum[dig2];
}
++lcount;

for(int i=0;i<size;i++)
{
arr[i]=outputarray[i];
}

}


displayarray(outputarray,size);
}




















int displayarray(int arr[],int size)
{
printf("the output array is\n");
for(int i=0;i<size;i++)
{
printf("%d ",arr[i]);
}

}





void main()
{
printf("enter size\n");
int size;
scanf("%d",&size);
int arr[size];
printf("enter elements\n");
for(int i=0;i<size;i++)
{
int val;
scanf("%04d",&val);
arr[i]=val;
}

int length;

printf("enter the max length\n");
scanf("%d",&length);

radixsort(arr , size,length);



}