본문 바로가기 메뉴 바로가기

The Nights

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

The Nights

검색하기 폼
  • 분류 전체보기 (114)
    • 알고리즘 (17)
      • Python (6)
      • C++ (6)
    • CS (0)
    • Backend (21)
      • 로드맵 (1)
      • Java (17)
      • Spring (3)
      • Spring Framework (0)
      • Spring Boot (0)
    • TIL (0)
    • Flutter (13)
    • Python (8)
      • 디스코드 챗봇 (1)
      • 문법 (2)
      • 머신러닝 (2)
    • C (28)
      • 문법 (19)
    • ETC (10)
      • Git (3)
      • GitHub (1)
      • Hacking (4)
    • Game (13)
      • Unity (13)
  • 방명록

scanf (1)
[C] 백준 1152 - 공백 포함 scanf

#include #include int main(void) { char sent[1000000]; int count=0; scanf("%[^\n]s", sent); int len = strlen(sent); for (int i = 0; i < len; i++) { if (sent[i] == ' ') count++; } if (sent[0] == ' ') count -= 1; if (sent[len - 1] == ' ') count -= 1; printf("%d", count+1); return 0; } scanf("%[^\n]s", sent); // 엔터 전까지 입력받기 위해 원래 gets(sent);로 했는데 백준에서 컴파일 에러나서... scanf로 했다.

C/문법 2022. 4. 25. 01:26
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • generics
  • DART
  • github
  • scanf
  • 1546
  • 1152
  • Failed to create GICache
  • C심화
  • sourcetree
  • 콘솔창
  • 자료형
  • 코뮤니티
  • Unity
  • 문자열 함수
  • 형변환
  • 미로찾기
  • 백준
  • 공백포함
  • 11720
  • 이중포인터
  • TensorFlow
  • 동적할당
  • nullsafety
  • split
  • 2차원 배열
  • 아스키코드
  • 이미지분류
  • 절대강좌유니티
  • C
  • c언어
more
«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바