일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 구글
- 클라우드
- Associate
- 쿠버네티스
- go
- Dataproc
- cdk
- 코세라
- nnictl
- 구글클라우드서밋
- 도커
- aws
- docker
- 딥러닝
- 클라우드 자격증
- 머신러닝
- coursera
- cloud
- GCP
- Kubernest
- 구글 클라우드
- 네트워크
- DataFlow
- golang
- 자격증
- 구글클라우드플랫폼
- 구글클라우드
- 마이크로서비스
- AWS #빅데이터 #분석 #데이터
- Today
- Total
JD의 블로그
[C language] Printing a histogram of the lengths of words 본문
[C language] Printing a histogram of the lengths of words
GDong 2019. 6. 7. 15:32#include
#define MAX 100
int main()
{
int w, nwords[MAX] ={0}, i=0;
while ((w=getchar())!=EOF) // Control + Z 누를 때까지 실행
{
if (w==' '||w== '\t' || w=='\n') // 띄어쓰기, tab, 줄바꾸기하면 새로운 단어로 인식
++i;
else
++nwords[i]; // nwords[i]번째 단어의 내용을 입력시마다 횟수 올림
}
for (i=0; i<MAX;i++){
printf("\n");
for (; nwords[i]>0; nwords[i]--) // nwords[i]의 값을 줄이며 0보다 클때만 * 출력
printf("*");
if(nwords[i+1]==0) // nwords array 다음 번에 단어가 있는지 없는지 판단
break;
printf("\n");
}
printf("\n");
return 0;
}
'-프로그래밍 언어 > C language' 카테고리의 다른 글
[C language] Reading a File to the End (0) | 2019.06.14 |
---|---|
[C language] array and rand (0) | 2019.06.09 |
[C language] scanf (0) | 2019.06.07 |
[C language] EOF (0) | 2019.06.07 |