'C언어'에 해당되는 글 12건

  1. 2008.08.12 가장 먼저오는 알파벳 출력
  2. 2008.08.12 학점출력
KOREA University/C2008. 8. 12. 14:53
영문자 3개를 받아들여 이 중 알파벳 순서에 가장 먼저 오는 영문자를 출력하는 프로그램입니다. 이정도는 너무 쉬워서 할말이 없지요...

#include <stdio.h>

void main()
{
 char ch1, ch2, ch3;
 
 printf("영문자를 입력하세요 : ");
 scanf("%c %c %c",&ch1, &ch2, &ch3);

 if(ch1>ch2 && ch3>ch2)
  printf("결과 : %c\n",ch2);
 
 if(ch1>ch3 && ch2>ch3)
  printf("결과 : %c\n",ch3);
 
 if(ch2>ch1 && ch3>ch1)
  printf("결과 : %c\n",ch1);
}

Posted by 정훈승
KOREA University/C2008. 8. 12. 14:47
아주 기본적인 학점 출력프로그램입니다. 90넘으면 A, 80넘으면 B...이런식으로

#include <stdio.h>

void main()
{
 int score;
 char grade;

 printf("점수를 입력해봐 : ");
 scanf("%d", &score);

 switch (score/10)
 {
  case 10:
  case 9: grade = 'A'; break;
  case 8: grade = 'B'; break;
  case 7: grade = 'C'; break;
  case 6: grade = 'D'; break;
  default : grade = 'F';
 }
 printf("%c\n", grade);
}

Posted by 정훈승