Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[1502] Re:문자열을 입력받아서 알파벳이나 숫자나 그외의 문자 갯수 출력하는 프로그램인데...
조준회 [] 1614 읽음    2002-11-08 08:28
일단 힌트만 드리겠씁니다.

첫번째 character는 항상 맨 처음만 가리키게됩니다.
두번째 위와 동일
       세번째것 처럼 character[i] 형식으로 하던가 해야 함.

세번째 for 문의위치가 잘못되었슴.
       이건 플로우차트를 한번 그려보시면.. 단번에 이해를 하실수 있을겁니다.


박중혁 님이 쓰신 글 :
: 제가 하면서 한 3가지 경우로 만들어 봤는데...뭐가 잘못됬는지...고수분들의 조언 부탁 드립니다...
:
: 맨첫번째가..
:
: #include <stdio.h>
: #include <ctype.h>
: void main(void)
: {char character[50];
:  void find_x(char[]);
:  printf("type a sentance: ");
:  gets(character);
:  find_x(character);
: }
:
:  void find_x(char character[])
:  {
:   int blank=0,alpha=0,digit=0,other=0;
:   while ((char)character!='\n')
:   {
:     if ((char) character==' ')
:     ++blank;
:     else if (isalpha((char)character))
:     ++alpha;
:     else if (isdigit((char)character))
:     ++digit;
:     else
:     ++other;
:   }
:   printf("알파벳:%s 숫자:%s 그외%s",alpha,digit,other+blank);
:  }
:
: 두번째가
: #include <stdio.h>
: #include <ctype.h>
: void main(void)
: {char character[50];
:  void find_x(char[]);
:  printf("type a sentance: ");
:  gets(character);
:  find_x(character);
: }
:
:  void find_x(char character[])
:  {
:   int c,blank=0,alpha=0,digit=0,other=0;
:   while ((c=getchar())!='\o')
:     if ((char) c==' ')
:     ++blank;
:     else if (isalpha(c))
:     ++alpha;
:     else if (isdigit(c))
:     ++digit;
:     else
:     ++other;
:
:   printf("알파벳:%s 숫자:%s 그외",alpha,digit,other+blank);
:  }
:
: 마지막으로...
: #include <stdio.h>
: #include <ctype.h>
: void main(void)
: {char character[50];
:  void find_x(char[]);
:  printf("type a sentance: ");
:  gets(character);
:  find_x(character);
: }
:
:  void find_x(char character[])
:  {
:   int i,c,blank=0,alpha=0,digit=0,other=0;
:   while(character[i]!='\o')
:   {
:     for (i=0;i<50;++i)
:     {
:     if (character[i]==' ')
:     ++blank;
:     else if (isalpha(character[i]))
:     ++alpha;
:     else if (isdigit(character[i]))
:     ++digit;
:     else
:     ++other;
:     }
:
:   }
:  printf("알파벳:%s 숫자:%s 그외",alpha,digit,other+blank);
:  }
:
: 먼가 쉬운것이 잘못된거 같은데 잘모르겠네요...좀 허접 하더라도 양해 부탁 드립니다...

+ -

관련 글 리스트
1501 문자열을 입력받아서 알파벳이나 숫자나 그외의 문자 갯수 출력하는 프로그램인데... 박중혁 1829 2002/11/08
1503     흐흐... STL을 사용하는 방법... *^^* 김백일 1385 2002/11/08
1502     Re:문자열을 입력받아서 알파벳이나 숫자나 그외의 문자 갯수 출력하는 프로그램인데... 조준회 1614 2002/11/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.