From 1cae06624c24366368a6af03483b60d9f8e67019 Mon Sep 17 00:00:00 2001 From: PouriaDianati Date: Sun, 17 Apr 2022 21:29:19 +0430 Subject: [PATCH] anjam shod --- 1.cpp | 16 ++++++++-------- 2.cpp | 14 +++++++++----- 3.cpp | 24 +++++++++++++++--------- 4.cpp | 3 ++- 5.cpp | 7 ++++--- 6.cpp | 1 + 7.cpp | 3 ++- 8.cpp | 1 + README.md | 2 -- 9 files changed, 42 insertions(+), 29 deletions(-) delete mode 100644 README.md diff --git a/1.cpp b/1.cpp index fedde2c..b4739ce 100644 --- a/1.cpp +++ b/1.cpp @@ -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; } @@ -26,7 +24,7 @@ void checkZeros(long long *a) { for (int i = 9; i >= 0; i--) { - if (a[i] = 0) + if (a[i] == 0) cout << "Zero Found" << endl; } } @@ -34,8 +32,8 @@ void checkZeros(long long *a) 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++) { @@ -47,4 +45,6 @@ int main() cout<<"Bye"; -} \ No newline at end of file +} + +// moteasefaneh har chi fekr kardam nafahmidan function producingTheFactorialFractions chikar mikone pas benazaram eshkal manteghi nadasht \ No newline at end of file diff --git a/2.cpp b/2.cpp index 6a27746..19ec44e 100644 --- a/2.cpp +++ b/2.cpp @@ -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; } @@ -24,4 +24,8 @@ int main() { char findIt; cin >> findIt; cout << countAllSpecificChars(sArr, 4, findIt); -} \ No newline at end of file +} + +//line 8 : count = 0 +//line 9, 10 : <= -> < +//line 12 : = -> == \ No newline at end of file diff --git a/3.cpp b/3.cpp index 77eb722..46df9da 100644 --- a/3.cpp +++ b/3.cpp @@ -1,9 +1,10 @@ #include #include +#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; @@ -18,8 +19,8 @@ void push(int x) if (!front) front = node; else { - rear->next = node; rear = node; + front->next = rear; } } @@ -45,7 +46,7 @@ void search(int x) printf("ERROR2"); break; } - node = node->next; + node = node->next; } void rpop() {//pop last element @@ -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]); } @@ -88,7 +89,7 @@ int average() { alfaptr node = front; - int sum = 0, count; + int sum = 0, count = 0; while (node) { sum += node->x; count++; @@ -97,7 +98,7 @@ int average() return sum / count; } -void main() +int main() { int cmd; long long int x; @@ -133,4 +134,9 @@ void main() exit(0); } } -} \ No newline at end of file +} +// 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 \ No newline at end of file diff --git a/4.cpp b/4.cpp index a9a32f2..fd8e086 100644 --- a/4.cpp +++ b/4.cpp @@ -6,4 +6,5 @@ int main() float *ptr2 = ptr1 + 3; printf("%f", *ptr2 - *ptr1); return 0; -} \ No newline at end of file +} +//javab 78; miad khune 4th araye ro az khune 1st kam mikone \ No newline at end of file diff --git a/5.cpp b/5.cpp index 1be3d10..16e3eae 100644 --- a/5.cpp +++ b/5.cpp @@ -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; -} \ No newline at end of file +} +// 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 \ No newline at end of file diff --git a/6.cpp b/6.cpp index f8b3141..520fe3d 100644 --- a/6.cpp +++ b/6.cpp @@ -9,3 +9,4 @@ int main() printf("%d\n", a); return 0; } +//javab 513 \ No newline at end of file diff --git a/7.cpp b/7.cpp index 7b065a0..901e2ab 100644 --- a/7.cpp +++ b/7.cpp @@ -7,4 +7,5 @@ int main() p += 2; printf("%d", *p); return 0; -} \ No newline at end of file +} +//oomad khune avale araye ro 2 kard va raft khune sevom ro print kard ke shod 3 \ No newline at end of file diff --git a/8.cpp b/8.cpp index ac3d613..bec8354 100644 --- a/8.cpp +++ b/8.cpp @@ -11,3 +11,4 @@ int main() { } +// chap mikone Be WooW \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 83cba6d..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# ApLabGitPractice -A Repo for My Students in Advanced Programming Workshop to practice what they have learn about Git & GitHub