C++
-
HackerRank.com Practice > C++ > Introduction > Variable Sized Arrayshackerrank.com 2020. 4. 17. 08:22
hackerrank.com Problem Link : https://www.hackerrank.com/challenges/variable-sized-arrays/problem?h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen #include #include using namespace std; int main() { int lenVector, lenQuery; cin >> lenVector; cin >> lenQuery; vector vs(lenVector); for (int i = 0; i > n; for..
-
HackerRank.com Practice > C++ > Introduction > Arrays Introductionhackerrank.com 2020. 4. 17. 07:29
hackerrank.com Problem Link : https://www.hackerrank.com/challenges/arrays-introduction/problem?h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen #include #include #include #include #include using namespace std; int main() { int N; cin >> N; int as[N]; for(int i=0; i> as[i]; for(int i=N-1; i>=0; --i) cout
-
HackerRank.com Practice > C++ > Introduction > Pointerhackerrank.com 2020. 4. 17. 07:26
hackerrank.com Problem Link : https://www.hackerrank.com/challenges/c-tutorial-pointer/problem?h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen #include #include void update(int *a,int *b) { // Complete this function int a1 = *a + *b; *b = abs(*a - *b); *a = a1; } int main() { int a, b; int *pa = &a, *pb = &b; scanf("%d %d", &a, &b); update(pa, pb); printf("%d\n%d", a, b); return 0; }
-
HackerRank.com Practice > C++ > Introduction > Functionshackerrank.com 2020. 4. 17. 07:17
#include #include using namespace std; /* Add `int max_of_four(int a, int b, int c, int d)` here. */ int max_of_four(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); } int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int ans = max_of_four(a, b, c, d); printf("%d", ans); return 0; }
-
HackerRank.com Practice > C++ > Introduction > For Loophackerrank.com 2020. 4. 17. 07:03
#include #include using namespace std; int main() { string ss[] = {"", "one", "two", "three", "four", "five",\ "six", "seven", "eight", "nine"}; string eo[] = {"even", "odd"}; int n, N; cin >> n >> N; for(int i=n; i
-
HackerRank.com Practice > C++ > Introduction > Conditional Statementshackerrank.com 2020. 4. 16. 20:27
#include #include using namespace std; int main() { int n; cin >> n; cin.ignore(numeric_limits::max(), '\n'); string ss[] = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "Greater than 9"}; n = (n>9)? 10: n; cout