diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..0cf5ea5 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": "No Configurations" +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..a25bbb0 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\8.cpp", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/git/v16/.suo b/.vs/git/v16/.suo new file mode 100644 index 0000000..3fd0469 Binary files /dev/null and b/.vs/git/v16/.suo differ diff --git a/.vs/git/v16/Browse.VC.db b/.vs/git/v16/Browse.VC.db new file mode 100644 index 0000000..7203d12 Binary files /dev/null and b/.vs/git/v16/Browse.VC.db differ diff --git a/.vs/git/v16/ipch/AutoPCH/29b7c175b8044611/1.ipch b/.vs/git/v16/ipch/AutoPCH/29b7c175b8044611/1.ipch new file mode 100644 index 0000000..7293544 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/29b7c175b8044611/1.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/40b1a39abe1e1292/8.ipch b/.vs/git/v16/ipch/AutoPCH/40b1a39abe1e1292/8.ipch new file mode 100644 index 0000000..cc71896 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/40b1a39abe1e1292/8.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/5d30ec4cd1244ac5/5.ipch b/.vs/git/v16/ipch/AutoPCH/5d30ec4cd1244ac5/5.ipch new file mode 100644 index 0000000..f9aeb46 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/5d30ec4cd1244ac5/5.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/649b1f802e9f0680/1.ipch b/.vs/git/v16/ipch/AutoPCH/649b1f802e9f0680/1.ipch new file mode 100644 index 0000000..5f8544c Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/649b1f802e9f0680/1.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/69c0f601183a3c43/2_FIX.ipch b/.vs/git/v16/ipch/AutoPCH/69c0f601183a3c43/2_FIX.ipch new file mode 100644 index 0000000..66521b2 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/69c0f601183a3c43/2_FIX.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/718967675c6f9768/6.ipch b/.vs/git/v16/ipch/AutoPCH/718967675c6f9768/6.ipch new file mode 100644 index 0000000..184ff76 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/718967675c6f9768/6.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/88c81aff057dba3c/1_FIX.ipch b/.vs/git/v16/ipch/AutoPCH/88c81aff057dba3c/1_FIX.ipch new file mode 100644 index 0000000..09283b6 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/88c81aff057dba3c/1_FIX.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/90cc71bdafba3e47/8.ipch b/.vs/git/v16/ipch/AutoPCH/90cc71bdafba3e47/8.ipch new file mode 100644 index 0000000..4844a61 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/90cc71bdafba3e47/8.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/c31a5d719a7ef30b/3.ipch b/.vs/git/v16/ipch/AutoPCH/c31a5d719a7ef30b/3.ipch new file mode 100644 index 0000000..6380298 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/c31a5d719a7ef30b/3.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/cbf1c62ad258638c/3_FIX.ipch b/.vs/git/v16/ipch/AutoPCH/cbf1c62ad258638c/3_FIX.ipch new file mode 100644 index 0000000..3b8af08 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/cbf1c62ad258638c/3_FIX.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/d74d4b6b793c202e/4.ipch b/.vs/git/v16/ipch/AutoPCH/d74d4b6b793c202e/4.ipch new file mode 100644 index 0000000..42361d1 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/d74d4b6b793c202e/4.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/e9ce3a7841284eb4/2.ipch b/.vs/git/v16/ipch/AutoPCH/e9ce3a7841284eb4/2.ipch new file mode 100644 index 0000000..f4002e4 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/e9ce3a7841284eb4/2.ipch differ diff --git a/.vs/git/v16/ipch/AutoPCH/f6758c73d0a6c57f/7.ipch b/.vs/git/v16/ipch/AutoPCH/f6758c73d0a6c57f/7.ipch new file mode 100644 index 0000000..8d76863 Binary files /dev/null and b/.vs/git/v16/ipch/AutoPCH/f6758c73d0a6c57f/7.ipch differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..2573363 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/1.cpp b/1.cpp index fedde2c..958e92e 100644 --- a/1.cpp +++ b/1.cpp @@ -4,29 +4,30 @@ 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; } } @@ -34,7 +35,7 @@ void checkZeros(long long *a) int main() { - long long int *a; + long long int* a; a = producingTheFactorialFractions(); checkZeros(a); for (int i = 0; i < 10; i++) @@ -43,8 +44,4 @@ int main() } delete a; - cout<<"hello"; - cout<<"Bye"; - - -} \ No newline at end of file +} diff --git a/2.cpp b/2.cpp index 6a27746..945f520 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,4 @@ int main() { char findIt; cin >> findIt; cout << countAllSpecificChars(sArr, 4, findIt); -} \ No newline at end of file +} diff --git a/3.cpp b/3.cpp index 77eb722..5fc8b37 100644 --- a/3.cpp +++ b/3.cpp @@ -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; @@ -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() @@ -31,6 +36,7 @@ void pop() else { node = front->next; + free(front); front = node; } } @@ -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; } -} \ No newline at end of file diff --git a/4.cpp b/4.cpp index a9a32f2..892a181 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 +} +//doroste \ No newline at end of file diff --git a/5.cpp b/5.cpp index 1be3d10..3f0ba20 100644 --- a/5.cpp +++ b/5.cpp @@ -7,4 +7,5 @@ int main() printf("%d\n", (*ptr2 - *ptr1)); printf("%c", (char)(*ptr2 - *ptr1)); return 0; -} \ No newline at end of file +} +//doroste \ No newline at end of file diff --git a/6.cpp b/6.cpp index f8b3141..8b86e71 100644 --- a/6.cpp +++ b/6.cpp @@ -9,3 +9,4 @@ int main() printf("%d\n", a); return 0; } +//doroste \ No newline at end of file diff --git a/7.cpp b/7.cpp index 7b065a0..6de6a52 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 +} +//doroste \ No newline at end of file diff --git a/8.cpp b/8.cpp index d851551..3a3cfe4 100644 --- a/8.cpp +++ b/8.cpp @@ -1,6 +1,6 @@ #include const char * f(const char **p) { - auto q = (p + sizeof(char))[1]; + const char * q = (p + sizeof(char))[1]; return q; } int main() { diff --git a/git b/git new file mode 100644 index 0000000..e69de29