Skip to content
Open

ap #50

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
3 changes: 1 addition & 2 deletions 1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace std;

long long *b;
long long b[10];

long long int factorial(int n)
{
Expand All @@ -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--)
{
Expand Down
13 changes: 10 additions & 3 deletions 2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -21,7 +28,7 @@ int main() {
"ap",
"class"
};
char findIt;
string findIt;
cin >> findIt;
cout << countAllSpecificChars(sArr, 4, findIt);
}
4 changes: 3 additions & 1 deletion 3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct alfa {
long long x;
alfaptr next;
};

alfaptr rear = NULL, front = NULL;
void push(int x)
{
Expand All @@ -34,6 +35,7 @@ void pop()
front = node;
}
}

void search(int x)
{
alfaptr node = front;
Expand Down Expand Up @@ -97,7 +99,7 @@ int average()
return sum / count;
}

void main()
int main()
{
int cmd;
long long int x;
Expand Down
5 changes: 5 additions & 0 deletions 4.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include<stdio.h>
using namespace std;

int main()
{
float arr[5] = { 12.5, 10.0, 13.5, 90.5, 0.5 };
float *ptr1 = &arr[0];
float *ptr2 = ptr1 + 3;
printf("%f", *ptr2 - *ptr1);
return 0;

//the result
//78.000000
}
5 changes: 5 additions & 0 deletions 5.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include<stdio.h>
using namespace std;

int main()
{
int arr[] = { 10, 20, 30, 40, 50, 60 };
Expand All @@ -7,4 +9,7 @@ int main()
printf("%d\n", (*ptr2 - *ptr1));
printf("%c", (char)(*ptr2 - *ptr1));
return 0;

//the result
//50 , 2
}
5 changes: 5 additions & 0 deletions 6.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include<stdio.h>
using namespace std;

int main()
{
int a;
Expand All @@ -8,4 +10,7 @@ int main()
x[0] = 1;
printf("%d\n", a);
return 0;

//the result
//513
}
5 changes: 5 additions & 0 deletions 7.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include<stdio.h>
using namespace std;

int main()
{
int arr[] = { 1, 2, 3, 4, 5 };
Expand All @@ -7,4 +9,7 @@ int main()
p += 2;
printf("%d", *p);
return 0;

//the result
//3
}
4 changes: 3 additions & 1 deletion 8.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include<stdio.h>
using namespace std;
const char * f(const char **p) {
auto q = (p + sizeof(char))[1];
return q;
Expand All @@ -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

}