본문 바로가기

전체 글105

[React]서버로 데이터 보내기 1. axios 사용하여 데이터 전송 회원가입 창을 예시로 회원가입 버튼 클릭 시 데이터 전송하도록 구현. 이때 axios를 사용한다. //joinForm.jsx function postInfo(e) { e.preventDefault(); axios .post("http://localhost:8080/users", { //spring에서도 @Getmapping("/users") 통해 설정 userId: ID, password: PW, name: Name, email: Email, }).then((res) => { //데이터 전송 성공 시 response 받음 alert("회원가입 성공"); }) .catch(function (err) { //데이터 전송 실패 시 error 받음 alert("error는 .. 2023. 1. 2.
21921_블로그 ▶실버3 풀이 누적 합을 이용한다. 예제 1번을 예시로 들면 n = 5, x = 2 1 4 2 5 1 1 5 7 12 13 로 누적 합을 구한다. 이때, x = 2이므로 arr[i] - arr[i - 2]를 한 값들을 벡터에 넣고 내림차순 정렬한 뒤 최댓값이 몇 개 있는지 센다. 벡터에 들어가는 값은 6, 7, 6인데 실제로는 5, 6, 7, 6이어야 한다. 따라서 배열 맨 앞에 0을 넣고 구하는 것이 맞다. 코드 #include #include #include #include using namespace std; int visitor[250001]; vector sum; bool compare(int i, int j) { return j < i; } int main(void) { cin.tie(0); .. 2023. 1. 1.
[React] selected React에서는 selected를 사용할 수 없다. => value 를 사용한다. apple banana carrot 2022. 12. 27.
[HTML/CSS] flex 사용 시 가운데 정렬 기본 상태 //html 안녕하세요! hello! //css #outer_wrapper{ display: flex; } #inner_wrapper{ border: solid 1px black; } 1. flex-direction: column일 경우 align-items: center 사용 //css #outer_wrapper{ display: flex; flex-direction: column; align-items: center; } #inner_wrapper{ border: solid 1px black; } 2. flex-direction: row일 경우 justify-content:center 사용 //css #outer_wrapper{ display: flex; flex-direction: row.. 2022. 12. 7.
2583_영역 구하기 ▶실버1 풀이 2차원 bfs문제. 점을 기준으로 탐색하는게 아니라 영역기준이므로 다음과 같은 형태로 정사각형 네 꼭짓점 중 왼쪽 아래를 기준으로 잡는다. x, y 값이 주어지면 for문으로 해당 범위 내의 arr[x][y]의 값을 true로 바꿔준다. 모든 범위가 주어지고 나면 (0, 0)부터 (n - 1, m - 1)까지 돌며 bfs 실행. 코드 #include #include #include #include #include #include #include #include using namespace std; queue q; int r[4] = { 1, -1, 0, 0 }; int c[4] = { 0, 0, 1, -1 }; bool arr[251][251]; int land; vector ans; in.. 2022. 11. 11.
3184_양 ▶실버1 풀이 2차원 bfs문제. 울타리 안 한 영역마다 bfs를 돌려주고 그 영역 내의 양 수와 늑대 수를 세서 양 > 늑대 일 경우 양 수를 더해주고, 양 tmpv) { cnto += tmpo; } else { cntv += tmpv; } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int r, c; cin >> r >> c; for (int i = 0; i > garden[i][j]; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { if (visited[i][j].. 2022. 11. 10.