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

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()
void producingTheFactorialFractions(long long int* a[])
{
long long b[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);
*a[i] += (long long int)pow(factorial(10), 2.0) / (i + 1);
}
return b;
}

void checkZeros(long long *a)
void checkZeros(long long int* 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;
a = producingTheFactorialFractions();
long long int b[10] = { 0 };
long long int* a[10];
for (int i = 0; i < 10; i++) {
a[i] = &b[i];
}
producingTheFactorialFractions(a);
checkZeros(a);
for (int i = 0; i < 10; i++)
{
cout << a[i] << endl;
cout << *a[i] << endl;
}
delete a;

cout<<"hello";
cout<<"Bye";
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;// count meghdar dehi nashodeh bood
for (int i = 0; i < arrLength; ++i) // = dar <= lazem nist
for (int j = 0; j < sArr[i].length(); ++j) // = dar <= lazem nist
// if the jth char of the string is the specific char
if (sArr[i][j] = specificChar)
if (sArr[i][j] == specificChar) // bayad == gharar midad
count++;
return count;
}
Expand All @@ -24,4 +24,4 @@ int main() {
char findIt;
cin >> findIt;
cout << countAllSpecificChars(sArr, 4, findIt);
}
}
30 changes: 19 additions & 11 deletions 3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
#define MAX_SIZE 200
int arr[MAX_SIZE];

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

struct alfa {
long long x;
alfaptr next;
};

alfaptr rear = NULL, front = NULL;
void push(int x)
{
alfaptr node;
node = (alfaptr)malloc(sizeof(struct alfa));
node->x = x;
if (!front)
if (!front) {
node->next = front;//adress node bayad barabar front bashad
front = node;
}
else {
rear->next = node;
rear = node;
Expand All @@ -30,30 +33,33 @@ void pop()
printf("ERROR1");
else
{
node = front->next;
front = node;
node = front;//node bayad barabar front gharar begirad
front = front->next;
free(node);//hafezeh bayad azad shvad
}
}
void search(int x)
{
alfaptr node = front;
int counter = 0;
while (node)
while (node) {//{} faramoosh shode bood
if (node->x == x)
printf("%d", counter);
else {
printf("ERROR2");
break;
}
node = node->next;
}
}

void rpop() {//pop last element
alfaptr node = front;
while (node)
node = node->next;
rear = node;// aval adres dehi mikonim baad free
free(rear);
rear = node;

}

void set()
Expand All @@ -66,9 +72,11 @@ void set()
int size()
{
alfaptr node = front;
int count;
while (node)
count++;node = node->next;
int count = 0;//count meghdar dehi nashode
while (node != NULL) {//{} faramoosh shode bood
count++;
node = node->next;
}
return count;
}

Expand All @@ -88,7 +96,7 @@ int average()
{

alfaptr node = front;
int sum = 0, count;
int sum = 0, count = 0;//count meghdar dehi nashode
while (node) {
sum += node->x;
count++;
Expand Down Expand Up @@ -133,4 +141,4 @@ void main()
exit(0);
}
}
}
}