diff --git a/1.cpp b/1.cpp index fedde2c..e3f82a7 100644 --- a/1.cpp +++ b/1.cpp @@ -4,7 +4,7 @@ using namespace std; -long long *b; +long long b[10]; long long int factorial(int n) { @@ -13,7 +13,6 @@ long long int factorial(int n) long long int *producingTheFactorialFractions() { - long long b[10]; for (int i = 10; i >= 0; i--) { diff --git a/2.cpp b/2.cpp index 6a27746..3afb12e 100644 --- a/2.cpp +++ b/2.cpp @@ -4,13 +4,20 @@ using namespace std; // count all the specific char in the whole array of strings -int countAllSpecificChars(string sArr[], int arrLength, char specificChar) { +int countAllSpecificChars(string sArr[], int arrLength, string specificChar) { int count; + string s; 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) + s=sArr[i][j]; + if (s == specificChar) count++; + } + } + return count; } @@ -21,7 +28,7 @@ int main() { "ap", "class" }; - char findIt; + string findIt; cin >> findIt; cout << countAllSpecificChars(sArr, 4, findIt); } \ No newline at end of file diff --git a/3.cpp b/3.cpp index 77eb722..b545f7c 100644 --- a/3.cpp +++ b/3.cpp @@ -9,6 +9,7 @@ struct alfa { long long x; alfaptr next; }; + alfaptr rear = NULL, front = NULL; void push(int x) { @@ -34,6 +35,7 @@ void pop() front = node; } } + void search(int x) { alfaptr node = front; @@ -97,7 +99,7 @@ int average() return sum / count; } -void main() +int main() { int cmd; long long int x; diff --git a/4.cpp b/4.cpp index a9a32f2..ef3ded9 100644 --- a/4.cpp +++ b/4.cpp @@ -1,4 +1,6 @@ #include +using namespace std; + int main() { float arr[5] = { 12.5, 10.0, 13.5, 90.5, 0.5 }; @@ -6,4 +8,7 @@ int main() float *ptr2 = ptr1 + 3; printf("%f", *ptr2 - *ptr1); return 0; + + //the result + //78.000000 } \ No newline at end of file diff --git a/5.cpp b/5.cpp index 1be3d10..dc355f4 100644 --- a/5.cpp +++ b/5.cpp @@ -1,4 +1,6 @@ #include +using namespace std; + int main() { int arr[] = { 10, 20, 30, 40, 50, 60 }; @@ -7,4 +9,7 @@ int main() printf("%d\n", (*ptr2 - *ptr1)); printf("%c", (char)(*ptr2 - *ptr1)); return 0; + + //the result + //50 , 2 } \ No newline at end of file diff --git a/6.cpp b/6.cpp index f8b3141..80a3d19 100644 --- a/6.cpp +++ b/6.cpp @@ -1,4 +1,6 @@ #include +using namespace std; + int main() { int a; @@ -8,4 +10,7 @@ int main() x[0] = 1; printf("%d\n", a); return 0; + + //the result + //513 } diff --git a/7.cpp b/7.cpp index 7b065a0..b6bf691 100644 --- a/7.cpp +++ b/7.cpp @@ -1,4 +1,6 @@ #include +using namespace std; + int main() { int arr[] = { 1, 2, 3, 4, 5 }; @@ -7,4 +9,7 @@ int main() p += 2; printf("%d", *p); return 0; + + //the result + //3 } \ No newline at end of file diff --git a/8.cpp b/8.cpp index ac3d613..7da7034 100644 --- a/8.cpp +++ b/8.cpp @@ -1,4 +1,5 @@ #include +using namespace std; const char * f(const char **p) { auto q = (p + sizeof(char))[1]; return q; @@ -8,6 +9,7 @@ int main() { 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 result + //Be WooW }