전체 글
-
Time Conversion해커랭크(HackerRank) 2018. 8. 19. 17:41
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 123456789101112131415161718#include #include #include #include #include #includeusing namespace std; int main() { int h,m,s; char c[2]; scanf("%d:%d:%d%s",&h,&m,&s,c); if(!strcmp(c,"PM") && h != 12)h+=12; if(!strcmp(c,"AM") && h == 12)h = 0; printf("%02d:%02d:%02d\n",h,m,s); return 0;}Colored by Color Scriptercs
-
Grading Students해커랭크(HackerRank) 2018. 8. 19. 17:41
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364#include using namespace std; /* * Complete the gradingStudents function below. */vector gradingStudents(vector grades) { /* * Write your code here. */ vector arr; int size = grades.size(); for(int i = 0; i grades_item; cin.ignore(numeric_limits::max(..
-
Day 0: Mean, Median, and Mode해커랭크(HackerRank) 2018. 8. 19. 17:40
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include #include #include #include #include using namespace std; int getMode(const vector &array) { int mode = 0; int size = array.size(); int count = 0, max = 0; vector copy (array.size()); copy = array; sort (copy.begin(), copy.end()); int current = 0; for(int i =..
-
Breaking the Records해커랭크(HackerRank) 2018. 8. 19. 17:39
1. 문제 2. 알고리즘키워드 - 구현 * 문제 풀이 - 입력 된 첫 배열의 요소에서 이전 값이 다음 값보다 크다면 highCount ++ 증가 - 입력 된 첫 배열의 요소에서 이전 값이 다음 값보다 작다면 lowCount ++ 증가 -highCount 와 lowCount 를 vector 에 추가하여 출력 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106#include u..
-
Birthday Chocolate해커랭크(HackerRank) 2018. 8. 19. 17:37
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 123456789101112131415161718192021222324252627282930313233343536#include using namespace std; int solve(int n, vector s, int d, int m){ // Complete this function int sol = 0; for(int i = 0; i n; vector s(n); for(int s_i = 0; s_i > s[s_i]; } int d; int m; cin >> d >> m; int result = solve(n, s, d, m); cout
-
Divisible Sum Pairs해커랭크(HackerRank) 2018. 8. 19. 17:36
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int divisibleSumPairs(int n, int k, vector ar) { // Complete this function const int size = ar.size(); int sol = 0; for(int i =0; i n >> k; vector ar(n); for(int ar_i = 0; ar_i > ar[ar_i]; } int result = divisibleSumPairs(n, k, ar); cout
-
Migratory Birds해커랭크(HackerRank) 2018. 8. 19. 17:36
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int migratoryBirds(int n, vector ar) { // Complete this function int brr[6] = {0,}; const int size = ar.size(); for(int i = 0; i ar[ar_i]; } int result = migratoryBirds(n, ar); cout
-
Bon Appétit해커랭크(HackerRank) 2018. 8. 19. 17:35
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;int main() { /* Enter your code here. Read inpu..