Skip to content

Commit 28a383d

Browse files
authored
Add files via upload
1 parent 4dc0aa1 commit 28a383d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3509
-0
lines changed

9915103252.c

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include<stdio.h>
2+
3+
int i,j;
4+
int maze[5][5]={1,1,0,1,2,0,1,1,0,1,1,0,1,1,1,1,1,0,1,0,0,1,1,0};
5+
char sol[5][5];
6+
7+
void main(){
8+
solve();
9+
}
10+
11+
int solve(){
12+
if(move_right()){
13+
if(maze[i+1][j]){
14+
if(move_down()){
15+
solve();
16+
}
17+
}else{if(maze[i-1][j]){
18+
if(move_up()){
19+
solve();
20+
}
21+
}
22+
}
23+
}else{
24+
if(move_left()){
25+
if(maze[i+1][j]){
26+
if(move_down()){
27+
solve();
28+
}
29+
}else{if(maze[i-1][j]){
30+
if(move_up()){
31+
solve();
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
38+
39+
void move_up(){
40+
if(maze[i][j]==2){
41+
printf("\nGot the Cheese!\n");
42+
}
43+
while(pos[i][j]!=0 || i!=0){
44+
sol[i][j]='X';
45+
i--;
46+
}sol[i][j]='X';
47+
printf("\n%d,%d to\n",i,j);
48+
return 1;
49+
}
50+
51+
int move_down(){
52+
if(maze[i][j]==2){
53+
printf("\nGot the Cheese!\n");
54+
}
55+
while(pos[i][j]!=0 || i!=4){
56+
sol[i][j]='X';
57+
i++;
58+
}
59+
printf("\n%d,%d to\n",i,j);
60+
return 1;
61+
}
62+
63+
int move_right(){
64+
if(maze[i][j]==2){
65+
printf("\nGot the Cheese!\n");
66+
}
67+
while(pos[i][j]!=0 || j!=4){
68+
sol[i][j]='X';
69+
j++;
70+
}
71+
printf("\n%d,%d to\n",i,j);
72+
return 1;
73+
}
74+
75+
void move_left(){
76+
if(maze[i][j]==2){
77+
printf("\nGot the Cheese!\n");
78+
}
79+
while(pos[i][j]!=0 || j!=0){
80+
sol[i][j]='X';
81+
j--;
82+
}
83+
printf("\n%d,%d to\n",i,j);
84+
return 1;
85+
}

ArrayLCM.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<stdio.h>
2+
3+
void main(){
4+
int a[5],i,t=1,b,j,c[100],u=0,l,m=0;
5+
6+
for(i=0;i<5;i++){
7+
scanf("%d",a[i]);
8+
}
9+
10+
for(i=0;i<5;i++){
11+
for(j=1;j<a[i];j++){
12+
b=a[i];
13+
14+
if(b%j==0){
15+
c[u]=j;
16+
m++;
17+
b=b/j;
18+
u++;
19+
}
20+
21+
}
22+
}
23+
24+
for(l=0;l<m;l++){
25+
t=t*a[l];
26+
}
27+
28+
}

F7F8_Lab2.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include<stdlib.h>
2+
#include<conio.h>
3+
using namespace std;
4+
5+
int main(){
6+
7+
//KMP Algorithm
8+
9+
return 0;
10+
}

Hackerrank_Cookies.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <math.h>
4+
#include <stdlib.h>
5+
6+
int main() {
7+
long long int n,k;
8+
scanf("%lld %lld",n,k);
9+
long long int aray[n];
10+
int i;
11+
for(i=0;i<n;i++){
12+
scanf("%lld ",&aray[i]);
13+
}
14+
check(aray,n);
15+
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
16+
return 0;
17+
}
18+
19+
void check(long long int aray[], long long int n){
20+
int i;
21+
for(i=0;i<n;i++){
22+
if(aray[i]<7){
23+
make_sweet(aray);
24+
}
25+
}
26+
}
27+
28+
void make_sweet(long long int aray[]){
29+
int least, sleast, i, n=(sizeof(aray)/sizeof(aray[0])), min=aray[0];
30+
long long int naray[n];
31+
int smin=naray[0];
32+
for(i=0;i<n;i++){
33+
if(aray[i]<min){
34+
min=aray[i];
35+
}
36+
}
37+
least=min;
38+
for(i=0;i<n;i++){
39+
naray[i]=aray[i];
40+
if(naray[i]==min){
41+
naray[i]='\0';
42+
}
43+
}
44+
for(i=0;i<n;i++){
45+
if(naray[i]<smin){
46+
smin=aray[i];
47+
}
48+
}
49+
sleast=smin;
50+
for(i=0;i<n;i++){
51+
aray[i]=(least+(2*sleast));
52+
}
53+
}

Hackerrankmedian.c

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <math.h>
4+
#include <stdlib.h>
5+
6+
void sort(int aray[],int first,int last){
7+
int pivot,j,temp,i;
8+
9+
if(first<last){
10+
pivot=first;
11+
i=first;
12+
j=last;
13+
14+
while(i<j){
15+
while(aray[i]<=aray[pivot]&&i<last)
16+
i++;
17+
while(aray[j]>aray[pivot])
18+
j--;
19+
if(i<j){
20+
temp=aray[i];
21+
aray[i]=aray[j];
22+
aray[j]=temp;
23+
}
24+
}
25+
26+
temp=aray[pivot];
27+
aray[pivot]=aray[j];
28+
aray[j]=temp;
29+
sort(aray,first,j-1);
30+
sort(aray,j+1,last);
31+
32+
}
33+
34+
void median(int aray[],int n){
35+
printf("%d",aray[(n/2)+1]);
36+
}
37+
38+
int main(){
39+
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
40+
int n;
41+
scanf("%d",&n);
42+
int aray[n];
43+
int i;
44+
for(i=0;i<n;i++){
45+
scanf("%d ",&aray[i]);
46+
}
47+
sort(aray,0,(n-1));
48+
median(aray,n);
49+
return 0;
50+
};

Hexa.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
void main()
4+
{
5+
int i,j,a=1,n;
6+
scanf("%d",&n);
7+
for(i=1;i<=n;i++){
8+
for(j=1;j<=(n-1);j++){
9+
printf(" ");
10+
}
11+
for(j=1;j<=n;j++){
12+
printf("%d",j);
13+
}
14+
printf("/n");
15+
}
16+
}
17+

Instance place backtrack.c

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include<stdio.h>
2+
#include<stdbool.h>
3+
#include<stdlib.h>
4+
5+
void ini(int n){
6+
int array[2*n],i;
7+
8+
for(i=0;i<(2*n);i++){
9+
array[i]=0;
10+
}
11+
12+
if(fill(n,n,array)){
13+
printf("Array is: [");
14+
for(i=0;i<(2*n);i++){
15+
printf(" %d",array[i]);
16+
}
17+
printf(" ]");
18+
}else{
19+
printf("Not Possible!");
20+
}
21+
22+
}
23+
24+
fill(int n, int a, int array[])
25+
{
26+
if(a==0){
27+
return true;
28+
}
29+
int i;
30+
for(i=0;i<2*n-a-1;i++){
31+
if(array[i]==0 && array[i+(a+1)]==0){
32+
array[i]=array[i+(a+1)]=a;
33+
if(fill(n,a-1,array)){
34+
return true;
35+
}
36+
array[i]=array[i+(a+1)]=0;
37+
}
38+
}
39+
return false;
40+
}
41+
42+
int main(){
43+
ini(7);
44+
return false;
45+
}

LAB1.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<conio.h>
2+
#include<iostream>
3+
using namespace std;
4+
5+
//
6+
void main(){
7+
//Implementing Linear Search
8+
int n;
9+
int array[10]={1,2,3,4,5,6,7,8,9,10};
10+
cout<<"Which No. is to be searched?\n";
11+
cin>>n;
12+
linear_search(array,n);
13+
}
14+
15+
void linear_search(int *a, int b)
16+
{
17+
bool flag=false;
18+
int i=0;
19+
while(a[i]!='\0'){
20+
if(a[i]==b){
21+
cout<<"b is found at i position\n"<<endl;
22+
flag = true;
23+
}
24+
i++;
25+
}
26+
if(flag==false){
27+
char r;
28+
cout<<"No such No. can be seen in the array!!\n"<<endl;
29+
cout<<"Retry? (y/n)\n"<<endl;
30+
cin>>r;
31+
if(r=='y'){
32+
main();
33+
}else{
34+
exit(0);
35+
}
36+
}
37+
}

LCM.c

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include<stdio.h>
2+
3+
void main(){
4+
5+
int r[50],p[50],s[50],t[50],a,b,c,d,i,m,w,v,x,g,h;
6+
7+
printf("Enter No. 1: ");
8+
scanf("%d",&a);
9+
printf("Enter No. 2: ");
10+
scanf("%d",&b);
11+
printf("Enter No. 3: ");
12+
scanf("%d",&c);
13+
printf("Enter No. 4: ");
14+
scanf("%d",&d);
15+
16+
for( i=0;i<50;i++ ){
17+
r[i]=a*(i+1);
18+
p[i]=b*(i+1);
19+
s[i]=c*(i+1);
20+
t[i]=d*(i+1);
21+
}
22+
23+
for(m=0;m<50;m++){
24+
25+
for(w=0;w<50;w++){
26+
27+
if(r[m]==p[w]){g=r[m];}
28+
}}
29+
30+
for(v=0;v<50;v++){
31+
32+
for(x=0;x<50;x++){
33+
34+
if(s[v]==t[x]){h=s[v];}
35+
}}
36+
37+
for( i=0;i<50;i++ ){
38+
r[i]=a*(i+1);
39+
p[i]=b*(i+1);
40+
printf();
41+
}

0 commit comments

Comments
 (0)