Skip to content
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
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "No Configurations"
}
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\8.cpp",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/git/v16/.suo
Binary file not shown.
Binary file added .vs/git/v16/Browse.VC.db
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/29b7c175b8044611/1.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/40b1a39abe1e1292/8.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/5d30ec4cd1244ac5/5.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/649b1f802e9f0680/1.ipch
Binary file not shown.
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/718967675c6f9768/6.ipch
Binary file not shown.
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/90cc71bdafba3e47/8.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/c31a5d719a7ef30b/3.ipch
Binary file not shown.
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/d74d4b6b793c202e/4.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/e9ce3a7841284eb4/2.ipch
Binary file not shown.
Binary file added .vs/git/v16/ipch/AutoPCH/f6758c73d0a6c57f/7.ipch
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
23 changes: 10 additions & 13 deletions 1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@

using namespace std;

long long *b;
long long* b;

long long int factorial(int n)
{
return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}

long long int *producingTheFactorialFractions()
long long int* producingTheFactorialFractions()
{
long long b[10];
long long* b = new long long[10];

for (int i = 10; i >= 0; i--)
for (int i = 9; i >= 0; i--)
{
b[i] += (int)pow(factorial(10), 2.0) / (i + 1);
b[i] += pow(factorial(10), 2.0) / (i + 1);
}

return b;
}

void checkZeros(long long *a)
void checkZeros(long long* a)
{
for (int i = 9; i >= 0; i--)
{
if (a[i] = 0)
if (a[i] == 0)
cout << "Zero Found" << endl;
}
}

int main()
{

long long int *a;
long long int* a;
a = producingTheFactorialFractions();
checkZeros(a);
for (int i = 0; i < 10; i++)
Expand All @@ -43,8 +44,4 @@ int main()
}
delete a;

cout<<"hello";
cout<<"Bye";


}
}
10 changes: 5 additions & 5 deletions 2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ using namespace std;

// count all the specific char in the whole array of strings
int countAllSpecificChars(string sArr[], int arrLength, char specificChar) {
int count;
for (int i = 0; i <= arrLength; ++i)
for (int j = 0; j <= sArr[i].size(); ++j)
int count = 0;
for (int i = 0; i < arrLength; ++i)
for (int j = 0; j < sArr[i].size(); ++j)
// if the jth char of the string is the specific char
if (sArr[i][j] = specificChar)
if (sArr[i][j] == specificChar)
count++;
return count;
}
Expand All @@ -24,4 +24,4 @@ int main() {
char findIt;
cin >> findIt;
cout << countAllSpecificChars(sArr, 4, findIt);
}
}
192 changes: 115 additions & 77 deletions 3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define MAX_SIZE 200
int arr[MAX_SIZE];

typedef struct alfa * alfaptr;
typedef struct alfa* alfaptr;

struct alfa {
long long x;
Expand All @@ -16,11 +16,16 @@ void push(int x)
node = (alfaptr)malloc(sizeof(struct alfa));
node->x = x;
if (!front)
{
front = node;
rear = front;
}
else {
rear->next = node;
rear = node;
}

node->next = NULL;
}

void pop()
Expand All @@ -31,6 +36,7 @@ void pop()
else
{
node = front->next;
free(front);
front = node;
}
}
Expand All @@ -39,98 +45,130 @@ void search(int x)
alfaptr node = front;
int counter = 0;
while (node)
{
if (node->x == x)
printf("%d", counter);
else {
printf("ERROR2");
break;
}
counter++;

node = node->next;
}

printf("%d", counter);
}

void rpop() {//pop last element
alfaptr node = front;
while (node)
node = node->next;
free(rear);
rear = node;
}
if (!front)
return;

void set()
{
alfaptr node = front;
for (int i = 0; i < MAX_SIZE && node; i++, node = node->next)
arr[i] = node->x;
}
if (front->next == NULL)
front = NULL;
else
{

int size()
{
alfaptr node = front;
int count;
while (node)
count++;node = node->next;
return count;
}
alfaptr node = front;
while (node->next->next != NULL)
node = node->next;
alfa* lastNode = node->next;
node->next = NULL;
rear = lastNode;
free(lastNode);
}

void show()
{
if (!front) {
for (int i = 0; i < MAX_SIZE; i++)
printf("%d ", arr[i]);
void set()
{
if (!front)
return;

alfaptr node = front;
for (int i = 0; i < MAX_SIZE && node; i++, node = node->next)
arr[i] = node->x;
}
else

int size()
{
printf("ERROR3");
alfaptr node = front;
int count = 0;
while (node)
{
count++; node = node->next;
}
return count;
}
}

int average()
{
void show()
{
if (!front) {
for (int i = 0; i < MAX_SIZE; i++)
printf("%d ", arr[i]);
}
else
{
alfaptr node = front;
while (node)
{
printf("%lld ", node->x);
node = node->next;
}
}
}

alfaptr node = front;
int sum = 0, count;
while (node) {
sum += node->x;
count++;
node = node->next;
int average()
{
if (!front)
return 0;

alfaptr node = front;
int sum = 0, count = 0;
while (node) {
sum += node->x;
count++;
node = node->next;
}
return sum / count;
}
return sum / count;
}

void main()
{
int cmd;
long long int x;
while (true)
int main()
{
scanf("%d", &cmd);
switch (cmd)
int cmd;
long long int x;
while (true)
{
case 1://push
scanf("%lld", &x);
push(x);
break;
case 2://pop
pop();
break;
case 3://rpop
rpop();
break;
case 4://search
scanf("%lld", &x);
search(x);
break;
case 5://set
set();
break;
case 6://show
show();
break;
case 7://size
printf("%d", size());
break;
case 10:
exit(0);
scanf("%d", &cmd);
switch (cmd)
{
case 1://push
scanf("%lld", &x);
push(x);
break;
case 2://pop
pop();
break;
case 3://rpop
rpop();
break;
case 4://search
scanf("%lld", &x);
search(x);
break;
case 5://set
set();
break;
case 6://show
show();
break;
case 7://size
printf("%d", size());
break;
case 10:
exit(0);
}

printf("\n");
}



while (size())
pop();

return 0;
}
}
3 changes: 2 additions & 1 deletion 4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ int main()
float *ptr2 = ptr1 + 3;
printf("%f", *ptr2 - *ptr1);
return 0;
}
}
//doroste
3 changes: 2 additions & 1 deletion 5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ int main()
printf("%d\n", (*ptr2 - *ptr1));
printf("%c", (char)(*ptr2 - *ptr1));
return 0;
}
}
//doroste
1 change: 1 addition & 0 deletions 6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ int main()
printf("%d\n", a);
return 0;
}
//doroste
3 changes: 2 additions & 1 deletion 7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ int main()
p += 2;
printf("%d", *p);
return 0;
}
}
//doroste
2 changes: 1 addition & 1 deletion 8.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include<stdio.h>
const char * f(const char **p) {
auto q = (p + sizeof(char))[1];
const char * q = (p + sizeof(char))[1];
return q;
}
int main() {
Expand Down
Empty file added git
Empty file.