Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anjam shod #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
16 changes: 8 additions & 8 deletions 1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ 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 int* b)
{
long long b[10];

for (int i = 10; i >= 0; i--)
{
b[i] += (int)pow(factorial(10), 2.0) / (i + 1);
b[i] = (int)pow(factorial(10), 2.0) / (i + 1);
}
return b;
}
Expand All @@ -26,16 +24,16 @@ 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;
a = producingTheFactorialFractions();
long long int *a = new long long int[11];
a = producingTheFactorialFractions(a);
checkZeros(a);
for (int i = 0; i < 10; i++)
{
Expand All @@ -47,4 +45,6 @@ int main()
cout<<"Bye";


}
}

// moteasefaneh har chi fekr kardam nafahmidan function producingTheFactorialFractions chikar mikone pas benazaram eshkal manteghi nadasht
14 changes: 9 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,8 @@ int main() {
char findIt;
cin >> findIt;
cout << countAllSpecificChars(sArr, 4, findIt);
}
}

//line 8 : count = 0
//line 9, 10 : <= -> <
//line 12 : = -> ==
24 changes: 15 additions & 9 deletions 3.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)
#define MAX_SIZE 200
int arr[MAX_SIZE];

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

struct alfa {
long long x;
Expand All @@ -18,8 +19,8 @@ void push(int x)
if (!front)
front = node;
else {
rear->next = node;
rear = node;
front->next = rear;
}
}

Expand All @@ -45,7 +46,7 @@ void search(int x)
printf("ERROR2");
break;
}
node = node->next;
node = node->next;
}

void rpop() {//pop last element
Expand All @@ -66,15 +67,15 @@ void set()
int size()
{
alfaptr node = front;
int count;
int count = 0;
while (node)
count++;node = node->next;
count++; node = node->next;
return count;
}

void show()
{
if (!front) {
if (front) {
for (int i = 0; i < MAX_SIZE; i++)
printf("%d ", arr[i]);
}
Expand All @@ -88,7 +89,7 @@ int average()
{

alfaptr node = front;
int sum = 0, count;
int sum = 0, count = 0;
while (node) {
sum += node->x;
count++;
Expand All @@ -97,7 +98,7 @@ int average()
return sum / count;
}

void main()
int main()
{
int cmd;
long long int x;
Expand Down Expand Up @@ -133,4 +134,9 @@ void main()
exit(0);
}
}
}
}
// chon exit() int return mikone main ro int migozarim
// 2 ta count dasht ke mosavi 0 mizarim
// line 22, 23 avaz shod
// line 78 "!" bardashte shod
// line 76 nemidunam show mikhad chikar kone daghighan
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;
}
}
//javab 78; miad khune 4th araye ro az khune 1st kam mikone
7 changes: 4 additions & 3 deletions 5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
int main()
{
int arr[] = { 10, 20, 30, 40, 50, 60 };
int *ptr1 = arr;
int *ptr2 = arr + 5;
int* ptr1 = arr;
int* ptr2 = arr + 5;
printf("%d\n", (*ptr2 - *ptr1));
printf("%c", (char)(*ptr2 - *ptr1));
return 0;
}
}
// in yek comment chert baraye commit ast; in barname 60 - 10 ra hesab karde va be dalile inke 50 code asci 2 ast, 2 ra niz print mikonad
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;
}
//javab 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;
}
}
//oomad khune avale araye ro 2 kard va raft khune sevom ro print kard ke shod 3
1 change: 1 addition & 0 deletions 8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ int main() {


}
// chap mikone Be WooW
2 changes: 0 additions & 2 deletions README.md

This file was deleted.