<문제 1>
=================================================
#include <stdio.h>
int max(int* n);
int min(int* n);
int main(void)
{
int n[3];
printf("3개의 정수를 입력하시오 : ");
scanf("%d %d %d",n,n+1,n+2);
printf("%d, %d, %d 중 최대값은 : %d\n",*n,*(n+1),*(n+2),max(n));
printf("%d, %d, %d 중 최소값은 : %d\n",*n,*(n+1),*(n+2),min(n));
return 0;
}
int max(int* n)
{
int max;
if(*n >= *(n+1)) max = *n;
else max = *(n+1);
if(max < *(n+2)) max = *(n+2);
return max;
}
int min(int* n)
{
int min;
if(*n <= *(n+1)) min = *n;
else min = *(n+1);
if(min > *(n+2)) min = *(n+2);
return min;
}
=================================================
<문제 2>
=================================================
#include <stdio.h>
float fahrenheit(float); // 섭씨를 화씨로 변환
float celsius(float); // 화씨를 섭씨로 변환
int main(void)
{
float temp;
int choice;
printf("섭씨 입력 1, 화씨입력 2 : ");
scanf("%d",&choice);
if(choice == 1){
printf("섭씨 입력 : ");
scanf("%f",&temp);
printf("변화된 화씨 : %.2f\n",fahrenheit(temp));
}else{
printf("화씨 입력 : ");
scanf("%f",&temp);
printf("변화된 섭씨 : %.2f\n",celsius(temp));
}
return 0;
}
float fahrenheit(float temp)
{
return 1.8*temp+32.0;
}
float celsius(float temp)
{
return (temp-32.0)/1.8;
}
=================================================
=================================================
#include <stdio.h>
int max(int* n);
int min(int* n);
int main(void)
{
int n[3];
printf("3개의 정수를 입력하시오 : ");
scanf("%d %d %d",n,n+1,n+2);
printf("%d, %d, %d 중 최대값은 : %d\n",*n,*(n+1),*(n+2),max(n));
printf("%d, %d, %d 중 최소값은 : %d\n",*n,*(n+1),*(n+2),min(n));
return 0;
}
int max(int* n)
{
int max;
if(*n >= *(n+1)) max = *n;
else max = *(n+1);
if(max < *(n+2)) max = *(n+2);
return max;
}
int min(int* n)
{
int min;
if(*n <= *(n+1)) min = *n;
else min = *(n+1);
if(min > *(n+2)) min = *(n+2);
return min;
}
=================================================
<문제 2>
=================================================
#include <stdio.h>
float fahrenheit(float); // 섭씨를 화씨로 변환
float celsius(float); // 화씨를 섭씨로 변환
int main(void)
{
float temp;
int choice;
printf("섭씨 입력 1, 화씨입력 2 : ");
scanf("%d",&choice);
if(choice == 1){
printf("섭씨 입력 : ");
scanf("%f",&temp);
printf("변화된 화씨 : %.2f\n",fahrenheit(temp));
}else{
printf("화씨 입력 : ");
scanf("%f",&temp);
printf("변화된 섭씨 : %.2f\n",celsius(temp));
}
return 0;
}
float fahrenheit(float temp)
{
return 1.8*temp+32.0;
}
float celsius(float temp)
{
return (temp-32.0)/1.8;
}
=================================================