분류 전체보기
-
[HackerRank] Plus Minus c++Coding Test/HackerRank 2022. 7. 16. 21:49
problem Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with 6 places after the decimal. example arr = [1,1,0,-1,-1] There are n = 5 elements, two positive, two negative and one zero. Their ratios are 2/5 = 0.400000, 2/5 = 0.400000 and 1/5 = 0.200000. Results are printed as: 0.400000 0...
-
[HackerRank] Diagonal Difference c++Coding Test/HackerRank 2022. 7. 16. 20:58
problem Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal = 1 + 5 + 9. The right to left diagonal = 3 +5 +9. Their absolute difference is |15-17| = 2. sample input 3 11 2 4 4 5 6 10 8 -12 output 15 solution 왼쪽방향 대각선, 오른쪽 방향 대각선의 원소들의 합을 구한뒤 둘의 차를 구하는 문제이다. sample ..
-
[HackerRank] A Very Bing Sum c++Coding Test/HackerRank 2022. 7. 16. 20:32
Problem In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large. Function Description Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following parameter(s): - int ar[n]: an array of integers . sample input 5 1000000001 10..
-
[c++] std::accumulate 함수 vector sumProgramming/c++ 2022. 7. 16. 20:07
accumulate 함수 STL container의 원소의 합을 모두 구하고 싶을때 사용하면 유용한 함수. 1. accumulate 함수 헤더 파일 #include 2. 함수 원형 std::accumulate(const _INIT , const _INIT , int) 컨테이너의 iterator(반복자) , sum의 초기값을 Agument(인자)로 설정합니다. 3. return 값 컨테이너 원소들의 합을 모두 구한 int형으로 반환 4. 예제 #include #include #include int main() { std::vector nVec = {1,3,5,87,15}; int nSum = std::accumulate(nVec.begin(), nVec.end(), 0); std::cout
-
[Raspberry Pi] 라즈베리파이 ssh 원격접속 문제 해결Server/Raspberry Pi 2022. 7. 12. 22:32
저는 라즈베리파이를 WiFi연결해서 사용하려고 했지만 유선랜인 데스크탑과 무선랜인 WiFi의 IP주소 대역이 달라 원격 접속을 할 수 없었습니다. 그래서 라즈베리파이도 유선랜으로 연결하여 같은 IP대역대로 맞춰주니 원격접속이 가능했습니다. 라즈베리파이에 통신, ssh 등 프로그램을 설치해도 원격접속이 안된다면, 데스크탑과 라즈베리파이의 IP주소 대역대를 확인하세요. IP주소 대역대가 다르다면, 대역대를 맞춰주거나 포트포워딩을 통해 접속 할 수 있도록 설정해야 합니다. IP주소 대역대가 같다면, 분명 IPv4주소를 잘못 확인했거나, 설정(wifi Id, pw)오류, 통신에 필요한 프로그램을 설치하지 않아서 생긴 문제일 수 있습니다. 이번 글은 라즈베리파이에 ssh 원격접속이 안될 때 확인해야 하는 네트워크..
-
[Raspberry Pi] 홈서버 구축5 (라즈베리파이 os ) SSH 원격접속Server/Raspberry Pi 2022. 7. 12. 21:24
라즈베리파이로 원격접속을 하려면 제일 먼저! IP를 확인해야합니다. IP 주소 check! IP를 확인하는 방법은 다양하게 있습니다. 1. 모니터 연결 모니터 연결 후 ifconfig 명령어로 IPv4 주소를 확인하는 방법 $ ifconfig 2. nmap 포트스캐닝 툴인 nmap을 사용하여 IPv4주소를 확인하는 방법 nmap -sn 192.168.1.0/24 포트 스캔을 하기 위해서는 메인PC와 라즈베리파이가 같은 공유기를 사용하고 있어야 합니다. Raspberry Pi 주소를 확인할 수 있습니다. 3. 공유기 관리자 페이지 공유기의 관리자 페이지로 접속 후 할당된 ipv4주소를 확인합니다. 이 때에도 메인PC와 라즈베리파이가 같은 공유기를 사용하고 있어야 합니다. 등등 이외에도 다른 방법들이 있습니..