본문 바로가기
반응형

분류 전체보기798

문장내 공백 계산하는 프로그램.. /* 문장을 입력받아 그 문장내의 공백, 숫자, 문자 등의 개수를 계산하는 예제 프로그램 */ #include int main(void) { int c, blank_cnt=0, digit_cnt=0, letter_cnt=0, nl_cnt=0, other_cnt=0; while (( c=getchar() ) != EOF) /* braces not necessary */ if (c == ' ') ++blank_cnt; else if (c >= '0' && c = 'a' && c = 'A' && c 2007. 1. 22.
아스키 코드와 10진수 출력.. /* do while 문안에 while 문을 중첩한 ASCII 코드와 10진수를 출력하는 예제 프로그램 */ #include int main(void) { char c = '#'; int n = 1; do { while (n 2007. 1. 22.
10진수를 2진수로 바꾸는 프로그램.. #include #include int chnum_01(int); int chnum_02(int); static char tnum_01[100]; static char tnum_02[100]; void main(void) { int num_01, num_02; printf("Enter the number 1 [1-15] : "); scanf("%d",&num_01); printf("Enter the number 2 [1-15] : "); scanf("%d",&num_02); chnum_01(num_01); chnum_02(num_02); printf("%sn",tnum_01); printf("%sn",tnum_02); } int chnum_01(int num_01) { itoa(num_01, tnum_0.. 2007. 1. 22.
볼링점수 계산 프로그램... #include int a[22]; #define ERROR printf("Bad shot %d in frame %d.n",a[j],i+1); return; #define CHECK1 if (a[j] 10) #define CHECK2 if (a[j] 10-a[j-1]) #define OUTPUT1 if (a[j]) printf("%d",a[j]); else printf("-"); #define OUTPUT2 if (a[j] == 10-a[j-1]) { printf("/"); t += a[j+1]; } else OUTPUT1 void score_data() { int tx[10] = {0}; int i,j,t; printf(" 1 2 3 4 5 6 7 8 .. 2007. 1. 22.
반응형