Logo CodeXlog
  • Home
  • About
  • Recent Posts
  • 게시글
  • Tags
  • Dark Theme
    Light Theme Dark Theme System Theme
Logo Inverted Logo
  • 태그
  • Airline
  • Algorithms
  • Ansible
  • Arithmetic
  • Array
  • Autojump
  • AWS
  • Backjoon
  • Bublesort
  • C
  • CentOS
  • Deep-Learning
  • Django
  • Embeded
  • Embeded-System
  • Git
  • Git Bash
  • Github
  • GitLab
  • Hugo
  • Hugo-Toha Theme
  • Hydejack Theme
  • IaC
  • Jekyll
  • Level 17
  • Level 4
  • Loop
  • MacOS
  • Manual
  • Math
  • MinGW
  • Online-Judge
  • OpenCV
  • OS
  • Pattern
  • Prime Number
  • Programming Tips
  • Python
  • RHEL
  • Scanf
  • Sort
  • String
  • Study
  • System-Programming
  • Tensor-Flow
  • Terrafrom
  • Theory
  • Ubuntu
  • Upgrade
  • Vim
  • Window
  • 비교분석
  • 초기설정
Hero Image
Problem.1152

백준 단계별 문제집 문자열 모든 내용은 Git Hub에도있습니다. Problem.1152 1152번[단어의 개수] #include <stdio.h> #include <string.h> #include <stdlib.h> int main(){ int count=0,is_word=0; //is_word=0 =>until not using any word //is_word=1 =>wherever used any word before using space char input; //공백은 연속으로 나오는 일이 없으니 공백만 잘 체크해 주면 된다. while((input=getchar())!=EOF){ if(input==10){ if(is_word==1) count++; break; } if(input>32){ is_word=1; } else{ if(input==32&&is_word==0){//is space } else if(input==32&&is_word==1){ count++; is_word=0; } } } printf("%d\n",count ); } 문제에서 헷갈리는 부문이 있다. 1.시작이 공백 2.끝이 공백 두가지 경우를 어떻게 처리할것인가가 좀 헷갈렸다. [시작이 공백] 시작이 공백이고 아직 단어가 한번도 안나온 경우 시작이 공백이지만 이미 단어가 한번 나온경우 [끝이 공백] 마지막 문자가 Newline이고 is_word가 1이라면 이전에 글자가 있었던것

  • C
  • String
  • Backjoon
  • Online-Judge
2018년 5월 18일 금요일 | 1
바로가기
  • About
  • Recent Posts
  • Tags
Contact me:
  • codex.devlab@gmail.com
  • ehdwn1991
  • Codex

책임 고지: This theme is under MIT license. So, you can use it for non-commercial, commercial, or private uses. You can modify or distribute the theme without requiring any permission from the theme author. However, the theme author does not provide any warranty or takes any liability for any issue with the theme.