Skip to content

Commit 53f3fb8

Browse files
committed
added all cd program found
1 parent 3f09582 commit 53f3fb8

File tree

33 files changed

+1627
-0
lines changed

33 files changed

+1627
-0
lines changed

.vscode/c_cpp_properties.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [],
9+
"compilerPath": "/usr/bin/clang",
10+
"cStandard": "c17",
11+
"cppStandard": "c++14",
12+
"intelliSenseMode": "linux-clang-x64"
13+
}
14+
],
15+
"version": 4
16+
}

.vscode/launch.json

Whitespace-only changes.

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"string.h": "c"
4+
}
5+
}

.vscode/tasks.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: clang-10 build active file",
6+
"command": "/usr/bin/clang-10",
7+
"args": [
8+
"-fcolor-diagnostics",
9+
"-fansi-escape-codes",
10+
"-g",
11+
"${file}",
12+
"-o",
13+
"${fileDirname}/${fileBasenameNoExtension}"
14+
],
15+
"options": {
16+
"cwd": "${fileDirname}"
17+
},
18+
"problemMatcher": [
19+
"$gcc"
20+
],
21+
"group": {
22+
"kind": "build",
23+
"isDefault": true
24+
},
25+
"detail": "Task generated by Debugger."
26+
},
27+
{
28+
"type": "cppbuild",
29+
"label": "C/C++: gcc build active file",
30+
"command": "/usr/bin/gcc",
31+
"args": [
32+
"-fdiagnostics-color=always",
33+
"-g",
34+
"${file}",
35+
"-o",
36+
"${fileDirname}/${fileBasenameNoExtension}"
37+
],
38+
"options": {
39+
"cwd": "${fileDirname}"
40+
},
41+
"problemMatcher": [
42+
"$gcc"
43+
],
44+
"group": "build",
45+
"detail": "Task generated by Debugger."
46+
}
47+
],
48+
"version": "2.0.0"
49+
}

a.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mkdir "1. Program for Recursive Binary & Linear Search."
2+
mkdir "2. Program for Heap Sort."
3+
mkdir "3. Program for Merge Sort."
4+
mkdir "4. Program for Selection Sort."
5+
mkdir "5. Program for Insertion Sort."
6+
mkdir "6. Program for Quick Sort."
7+
mkdir "7. Knapsack Problem using Greedy Solution"
8+
mkdir "8. Perform Travelling Salesman Problem"
9+
mkdir "9. Find Minimum Spanning Tree using Kruskal’s Algorithm"
10+
mkdir "10. Implement N Queen Problem using Backtracking"
11+
mkdir "11. Sort a given set of n integer elements using Quick Sort method and compute its time complexity. Run the program for"
12+
mkdir "12. Sort a given set of n integer elements using Merge Sort method and compute its time complexity. Run the program for"
13+
mkdir "13.6. Implement , the 0/1 Knapsack problem using"
14+
mkdir "14. From a given vertex in a weighted connected graph, find shortest paths to other vertices using Dijkstra's algorithm."
15+
mkdir "15. Find Minimum Cost Spanning Tree of a given connected undirected graph using Kruskal's algorithm. Use Union-Find"
16+
mkdir "16. Find Minimum Cost Spanning Tree of a given undirected graph using Prim’s algorithm."
17+
mkdir "17. Write programs to (a) Implement All-Pairs Shortest Paths problem using Floyd's algorithm."
18+
mkdir "18. Design and implement to find a subset of a given set S = {Sl, S2,.....,Sn} of n positive integers whose SUM is equal to"
19+
mkdir "19. Design and implement to find all Hamiltonian Cycles in a connected undirected Graph G of n vertices using"

cd/1. la/input.txt

Whitespace-only changes.

cd/1. la/program

16.8 KB
Binary file not shown.

cd/1. la/program.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include <string.h>
2+
#include <ctype.h>
3+
#include <stdio.h>
4+
void main()
5+
{
6+
FILE *f1;
7+
char c, str[10];
8+
int lineno = 1, num = 0, i = 0, j = 0;
9+
// clrscr();
10+
printf("\nEnter the c program\n");
11+
12+
f1 = fopen("input.txt", "w");
13+
while ((c = getchar()) != 36)
14+
{
15+
putc(c, f1);
16+
}
17+
fclose(f1);
18+
19+
f1 = fopen("input.txt", "r");
20+
while ((c = getc(f1)) != EOF)
21+
{
22+
if (isdigit(c))
23+
{
24+
num = c - 48;
25+
c = getc(f1);
26+
while (isdigit(c))
27+
{
28+
num = num * 10 + (c - 48);
29+
c = getc(f1);
30+
}
31+
printf("%d is a number \n", num);
32+
ungetc(c, f1);
33+
}
34+
else if (isalpha(c) || c == 95)
35+
{
36+
str[i++] = c;
37+
c = getc(f1);
38+
while (isdigit(c) || isalpha(c) || c == 95 || c == 36)
39+
{
40+
str[i++] = c;
41+
c = getc(f1);
42+
}
43+
str[i++] = '\0';
44+
if (strcmp("for", str) == 0 || strcmp("while", str) == 0 || strcmp("do", str) == 0 || strcmp("int", str) == 0 || strcmp("float", str) == 0 || strcmp("char", str) == 0 || strcmp("double", str) == 0 || strcmp("static", str) == 0 || strcmp("switch", str) == 0 || strcmp("case", str) == 0) // TYPE 32 KEYWORDS
45+
printf("%s is a keyword\n", str);
46+
else
47+
printf("%s is a identifier\n", str);
48+
ungetc(c, f1);
49+
i = 0;
50+
}
51+
else if (c == ' ' || c == '\t')
52+
{
53+
printf("\n");
54+
j = j - 1;
55+
}
56+
else if (c == '\n')
57+
{
58+
lineno++;
59+
j = j - 1;
60+
}
61+
else
62+
{ // TO FIND SPECIAL SYMBOL
63+
printf("%c is a special symbol\n", c);
64+
}
65+
66+
j = j + 1;
67+
}
68+
69+
printf("Total no. of lines are: %d\n", lineno);
70+
printf("The total number of token is %d\n", j);
71+
fclose(f1);
72+
// getch();
73+
}
Binary file not shown.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Construct a recursive descent parser for an expression
2+
#include<stdio.h>
3+
#include<ctype.h>
4+
#include<string.h>
5+
char input[100];
6+
int i=0;
7+
8+
void E()
9+
{
10+
T();
11+
E1();
12+
}
13+
14+
15+
16+
void E1()
17+
{
18+
if(input[i]=='+')
19+
{
20+
i++;
21+
T();
22+
E1();
23+
}
24+
}
25+
26+
void T()
27+
{
28+
F();
29+
T1();
30+
}
31+
32+
void T1()
33+
{
34+
if(input[i]=='*')
35+
{
36+
i++;
37+
F();
38+
T1();
39+
}
40+
}
41+
42+
void F()
43+
{
44+
if(isalnum(input[i]))
45+
i++;
46+
else if(input[i]=='(')
47+
{
48+
i++;
49+
E();
50+
if(input[i]==')')
51+
i++;
52+
else
53+
{
54+
printf("Invalid expression\n");
55+
exit(0);
56+
}
57+
}
58+
else
59+
{
60+
printf("Invalid expression\n");
61+
exit(0);
62+
}
63+
}
64+
65+
void main()
66+
{
67+
printf("Enter the expression");
68+
scanf("%s",input);
69+
E();
70+
if(strlen(input)==i)
71+
printf("Valid expression \n");
72+
else
73+
printf("Invalid expression \n" );
74+
}

0 commit comments

Comments
 (0)