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
18 changes: 9 additions & 9 deletions 1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace std;

long long *b;
long long int *b;// :|

long long int factorial(int n)
{
Expand All @@ -13,28 +13,28 @@ long long int factorial(int n)

long long int *producingTheFactorialFractions()
{
long long b[10];
long long int* b = new long long int[10];//assigning memory.

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

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

int main()
{

long long int *a;
long long int *a = new long long int[10];//new assigning memory.
a = producingTheFactorialFractions();
checkZeros(a);
for (int i = 0; i < 10; i++)
Expand All @@ -43,8 +43,8 @@ int main()
}
delete a;

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


}
}
8 changes: 4 additions & 4 deletions 2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ 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)
for (int i = 0; i < arrLength; ++i)// chabging <= to <.
for (int j = 0; j < sArr[i].size(); ++j)//changing <= to <.
// if the jth char of the string is the specific char
if (sArr[i][j] = specificChar)
if (sArr[i][j] == specificChar)//changing = to ==.
count++;
return count;
}
Expand All @@ -24,4 +24,4 @@ int main() {
char findIt;
cin >> findIt;
cout << countAllSpecificChars(sArr, 4, findIt);
}
}
39 changes: 30 additions & 9 deletions 3.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 200
using namespace std;

int arr[MAX_SIZE];

typedef struct alfa * alfaptr;
Expand All @@ -15,9 +17,16 @@ void push(int x)
alfaptr node;
node = (alfaptr)malloc(sizeof(struct alfa));
node->x = x;
node->next = NULL;//added.

if (!front)
{
front = node;
else {
rear = node;//added.
}

else
{
rear->next = node;
rear = node;
}
Expand All @@ -27,7 +36,7 @@ void pop()
{
alfaptr node;
if (!front)
printf("ERROR1");
printf("ERROR1\n");
else
{
node = front->next;
Expand All @@ -39,21 +48,30 @@ void search(int x)
alfaptr node = front;
int counter = 0;
while (node)
{
if (node->x == x)
{
counter++;
printf("%d", counter);
else {
printf("ERROR2");
break;
}
counter++;
node = node->next;
}
if(counter == 0)
{
printf("ERROR@\n");
}
}


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

void set()
Expand All @@ -68,13 +86,16 @@ int size()
alfaptr node = front;
int count;
while (node)
count++;node = node->next;
{
count++;
node = node->next;//added.
}
return count;
}

void show()
{
if (!front) {
if (front) {//removing !.
for (int i = 0; i < MAX_SIZE; i++)
printf("%d ", arr[i]);
}
Expand All @@ -97,7 +118,7 @@ int average()
return sum / count;
}

void main()
int main()
{
int cmd;
long long int x;
Expand Down Expand Up @@ -133,4 +154,4 @@ void main()
exit(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;
}
//the program prints value of arr[3]-arr[0].(=78.0)
}
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;
}
//the program prints value of arr[5]-arr[0](=50) and convert previous result to char.
}
2 changes: 1 addition & 1 deletion 6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ int main()
a = 512;
x[0] = 1;
printf("%d\n", a);
return 0;
return 0;//the program prints 513.
}
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;
}
//the program prints 3.
}
2 changes: 1 addition & 1 deletion 8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
const char * str[] = { "Wish","You","Best",":D" };
printf("%c%c ", *f(str), *(f(str) + 1));
printf("%c%c%c%c\n", **str, *(*(str + 1) + 1), *((str + 2)[-1] + 1), **&*(&str[-1] + 1));

//the program prints 'Be' first and then prints 'WooW'.


}