메뉴 입력 예제에서 처음엔 scanf가 잘 받아지는데 스위치 문을 나가고 다시 메뉴가 보이고 scanf로 다른 글자를 받아야되는데 그게 한번 건너뛰어지고 다시 menu함수가 실행되서 Enter the letter of your choice 글자가 두번 중복되는 문제가 생깁니다. 디버그 해도 원인을 모르겠는데 왜 그런걸까요?..ㅠㅠ #include <stdio.h> char input; int num; void menu() { printf("Enter the letter of your choice: \n"); printf("a. avengers\t b. beep\n"); printf("c. count\t q. quit\n"); scanf("%c", &input); switch (input) { case 'a': printf("Avengers assemble!\n"); break; case 'b': printf("\a"); break; case 'c': scanf("%d", &num); for (int i = 1; i <=num; i++) { printf("%d\n", i); } break; default: break; } } int main() { do { menu(); } while (input != 'q'); return 0; }
안녕하세요:) 아래의 컨트롤 URI 부분에 질문에 있어서 질문드립니다. orders/{orderId}/start-delivery 위의 컨트롤 URI 를 아래와 같이 바꾸고 orders/{orderID} 해더에 아래와 같은 문장을 추가하여 해결하는 방법이 URI 는 리소스만을 생각한다는 부분에서 맞는 것 같다고 생각되는데 start-delivery: true 위의 생각이 업계에서 올바르게 사용될 수 있는 방법인지, 아니라면 어떤 부분이 문제인지 답변 부탁드립니다! 개인적인 생각으로 Header 부분이 거대해질 수 있다는 문제가 있을 것 같지만 URI 정의상으로는 어떻게든 Header 에 넣어서 요청을 보내는 것이 옳다고 생각하여 질문드립니다.
안녕하세요 제로초님 본 강의 8분 10초에서 나와있는 것처럼 프론트엔드의 프록시를 주석처리하고 cors문제를 해결하려고 했습니다. 로그인에 이렇게 url을 입력하고 로그인 요청을 보냈는데 . . 이렇게 에러가 뜹니다. withCredentials을 true로 활성화 해줘도 같은에러가 발생합니다. 뭐가 잘못된것일 까요?...
[C#과 유니티로 만드는 MMORPG 게임 개발 시리즈] Part1: C# 기초 프로그래밍 입문
제가 완벽하게 이해못한거같아 질문드립니다! 질문1. 대리자 딜리게이트를 쓰는이유 함수나 클래스내에 수많은 기능이 있고 그 모든 기능을 전부 쓸필요가 없다면 필요한 기능(함수)만 입력하여 반환 받아 사용하는 편리성? 역할이 맞는가요 질문2. 대리자 사용방법 수업을 들으며 3가지를 만들어야하는거 같았습니다 1. 대리자 delegate 2. 대리자가 사용할 함수(이걸 인자로 넘김) 3. 대리자 함수를 인자로 받으면 그에맞는 값을 반환하는함수 ================================== ( 수업에선 delegate int OnClicked(); ) (우리가 인자에 넣을)함수를 전해주는 대리자 delegate + 반환형식 + 대리자이름(); 여기서 대리자와 같은 형식이며 대리자와 같은 클래스내 함수들을 s라고 하면 메인함수에서 대리자 대 = new 대리자(); 로 객체 생성하고 대리자 대 = new 대리자(s); 또는 대 = s ; 대리자에 함수 전달 =================================== (수업에선 ButtonPressed(Onclicked clickedFunction)) 함수를 지닌 대리자 혹은 함수 자체를 인자로 받는 함수 하나 더 생성 static void Result( 함수 혹은 [함수가 담긴 대리자] ) { 함수(); } 역할은 인자로받은 함수내 필드값을 반환 해주는 함수 ====================================== 끝으로 대리자에 들어가는 함수들은 대리자와 같은 형식이어야하고 (같은 반환형식) 각 함수마다 필드내용은 다르게 설정가능?!? (콘솔명령어로 테스트해보니 그런거같아보여서요) static int test1(){ return 1; } static int test2(){ return 2; } 가 있다면 대리자에 test1함수를 넣고 대리자 혹은 test1함수를 result(대리자 인자)의 인자로 넣을시 1의 값을 반환 대리자에 test2함수를 넣으면 2의 값이 반환되는것이 맞나요? ====================================
안녕하십니까 제로초님 다름이아니라 제로초님 영상보면 예전에 JS 초급강좌 , JS 중급강좌가 따로 나뉘어져 있는대 1. 지금 개정판 let's Get it 자바스크립트는 중급강좌 내용까지 합쳐진 내용인가요 ? 2. 합쳐져 있거나 혹은 분리되어 있다면 어느 내용들이 빠져 있을까요? (포함된 내용이라도 모든 내용을 다 다루진 않으신거 같아서요!)
안녕하세요. 머신러닝/비지도 학습 공부 중 질문이 생겨서 이렇게 글을 남기게 되었습니다. K-Menas의 경우 우선, 중심값을 기준으로 거리를 측정해, 군집을 형성하는데, 1. 혹시 초기 군집값은 랜덤하게 생성을 해주는 것일가요? 2. 거리를 계산할 때도, 유클리드 거리 통해서 계산하는것으로 아는데, 항상 유클리드 거리로 계산을 하는지, 혹, 옵션을 통해서 맨해튼거리로도 계산이 가능한지 궁금합니다. 감사합니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요! 강의를 듣고 따라 해봤는데요 제가 똑같이 한다고 여러번 시도를 해봤는데 접히는 듯 보이게하는 부분을 아무리 펜툴을 써서 해도 잘 안되더라구요ㅠㅠ 똑같이 찍으라는 곳 찍고 했는데...어떻게 해야하나요
안녕하세요 김영한 팀장님! HttpServlet을 사용한 방식에서 String으로 변환하고자 할때 copyToString에서 charset을 설정해주었습니다. HttpEntity나 어노테이션 이용한 방식은 request시 들어온 문자열 및 나갈때 문자열 모두 default로 utf-8을 지정하는걸로 이해하면 될까요?
안녕하세요 실습 중 magicgrid.js에 var masonrys = document.getElementByTagName( 'img' ); for (let i = 0 ; i< masonrys.length; i++) { masonrys[i].addEventListener( 'load' , function () { magicGrid.positionItems(); }, false ); } 위 코드를 작성하면, 다음과 같이 화면이 뜹니다. div 태그들의 위치가 한 곳에 고정되어 모두 겹쳐서 나타나요. 이유가 무엇일까요? 작성한 코드를 첨부합니다.. {% extends 'base.html' %} {% load static %} {% block content %} <style> .container div { width: 250px; background-color: antiquewhite; display: flex; justify-content: center; align-items: center; border-radius: 1rem; } .container img { width : 100%; border-radius : 1rem; } </style> <div class ="container" > <div class ="item1" > <img src ="https://picsum.photos/200/300" > </div> <div class ="item2" > 2 </div> <div class ="item3" > 3 </div> <div class ="item4" > 4 </div> <div class ="item5" > 5 </div> <div class ="item6" > 6 </div> <div class ="item7" > 7 </div> <div class ="item8" > 8 </div> <div class ="item9" > 9 </div> <div class ="item10" > 10 </div> <div class ="item11" > 11 </div> <div class ="item12" > 12 </div> <div class ="item13" > 13 </div> </div> <script src ="{% static 'js/magicgrid.js' %}" ></script> {% endblock %} 'use strict' ; /** * @author emmanuelolaojo * @since 11/11/18 */ /** * Validates the configuration object. * * @param config - configuration object */ var checkParams = function (config) { var DEFAULT_GUTTER = 25 ; var booleanProps = [ "useTransform" , "center" ]; if (!config) { throw new Error( "No config object has been provided." ); } for ( var prop of booleanProps){ if ( typeof config[prop] !== "boolean" ){ config[prop] = true ; } } if ( typeof config.gutter !== "number" ){ config.gutter = DEFAULT_GUTTER; } if (!config.container) { error( "container" ); } if (!config.items && !config.static) { error( "items or static" ); } }; /** * Handles invalid configuration object * errors. * * @param prop - a property with a missing value */ var error = function (prop) { throw new Error(( "Missing property '" + prop + "' in MagicGrid config" )); }; /** * Finds the shortest column in * a column list. * * @param cols - list of columns * * @return shortest column */ var getMin = function (cols) { var min = cols[ 0 ]; for ( var col of cols) { if (col.height < min.height) { min = col; } } return min; }; /** * @author emmanuelolaojo * @since 11/10/18 * * The MagicGrid class is an * implementation of a flexible * grid layout. */ var MagicGrid = function MagicGrid (config) { checkParams(config); if (config.container instanceof HTMLElement) { this .container = config.container; this .containerClass = config.container.className; } else { this .containerClass = config.container; this .container = document.querySelector(config.container); } this .items = this .container.children; this .static = config.static || false ; this .size = config.items; this .gutter = config.gutter; this .maxColumns = config.maxColumns || false ; this .useMin = config.useMin || false ; this .useTransform = config.useTransform; this .animate = config.animate || false ; this .started = false ; this .center = config.center; this .init(); }; /** * Initializes styles * * @private */ MagicGrid.prototype.init = function init () { if (! this .ready() || this .started) { return ; } this .container.style.position = "relative" ; for ( var i = 0 ; i < this .items.length; i++) { var style = this .items[i].style; style.position = "absolute" ; if ( this .animate) { style.transition = ( this .useTransform ? "transform" : "top, left" ) + " 0.2s ease" ; } } this .started = true ; }; /** * Calculates the width of a column. * * @return width of a column in the grid * @private */ MagicGrid.prototype.colWidth = function colWidth () { return this .items[ 0 ].getBoundingClientRect().width + this .gutter; }; /** * Initializes an array of empty columns * and calculates the leftover whitespace. * * @return {{cols: Array, wSpace: number}} * @private */ MagicGrid.prototype.setup = function setup () { var width = this .container.getBoundingClientRect().width; var colWidth = this .colWidth(); var numCols = Math.floor(width/colWidth) || 1 ; var cols = []; if ( this .maxColumns && numCols > this .maxColumns) { numCols = this .maxColumns; } for ( var i = 0 ; i < numCols; i++) { cols[i] = {height: 0 , index: i}; } var wSpace = width - numCols * colWidth + this .gutter; return {cols: cols, wSpace: wSpace}; }; /** * Gets the next available column. * * @param cols list of columns * @param i index of dom element * * @return {*} next available column * @private */ MagicGrid.prototype.nextCol = function nextCol (cols, i) { if ( this .useMin) { return getMin(cols); } return cols[i % cols.length]; }; /** * Positions each item in the grid, based * on their corresponding column's height * and index then stretches the container to * the height of the grid. */ MagicGrid.prototype.positionItems = function positionItems () { var ref = this .setup(); var cols = ref.cols; var wSpace = ref.wSpace; var maxHeight = 0 ; var colWidth = this .colWidth(); wSpace = this .center ? Math.floor(wSpace / 2 ) : 0 ; for ( var i = 0 ; i < this .items.length; i++) { var col = this .nextCol(cols, i); var item = this .items[i]; var topGutter = col.height ? this .gutter : 0 ; var left = col.index * colWidth + wSpace + "px" ; var top = col.height + topGutter + "px" ; if ( this .useTransform){ item.style.transform = "translate(" + left + ", " + top + ")" ; } else { item.style.top = top; item.style.left = left; } col.height += item.getBoundingClientRect().height + topGutter; if (col.height > maxHeight){ maxHeight = col.height; } } this .container.style.height = maxHeight + this .gutter + "px" ; }; /** * Checks if every item has been loaded * in the dom. * * @return {Boolean} true if every item is present */ MagicGrid.prototype.ready = function ready () { if ( this .static) { return true ; } return this .items.length >= this .size; }; /** * Periodically checks that all items * have been loaded in the dom. Calls * this.listen() once all the items are * present. * * @private */ MagicGrid.prototype.getReady = function getReady () { var this$1 = this ; var interval = setInterval( function () { this$1.container = document.querySelector(this$1.containerClass); this$1.items = this$1.container.children; if (this$1.ready()) { clearInterval(interval); this$1.init(); this$1.listen(); } }, 100 ); }; /** * Positions all the items and * repositions them whenever the * window size changes. */ MagicGrid.prototype.listen = function listen () { var this$1 = this ; if ( this .ready()) { var timeout; window.addEventListener( "resize" , function () { if (!timeout){ timeout = setTimeout( function () { this$1.positionItems(); timeout = null ; }, 200 ); } }); this .positionItems(); } else { this .getReady(); } }; let magicGrid = new MagicGrid({ container: '.container' , animate: true , gutter: 30 , static: true , useMin: true }); var masonrys = document.getElementByTagName( 'img' ); for (let i = 0 ; i< masonrys.length; i++) { masonrys[i].addEventListener( 'load' , function () { magicGrid.positionItems(); }, false ); } magicGrid.listen();
선생님 컨텍스트 API 강의에서는 createContext로 저장소를 만들고 useContext로 이용한다고 배웠는데 지금 나온 ThemeContext가 createContext 역할을 대신 해주는건가요? 그럼 createContext 에서 코드 짤 때 return <Context.Provider value={value}>{children}</Context.Provider> 이렇게 Provider로 감싸는 작업은 따로 없는건가요?? ThemeContext가 지금 App 전체를 감싸고 있는건가요? 헷갈려요 ㅠㅠ