728x90
반응형
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int grade[5];
int maximum;

void InputData()
{
	for (int i = 0; i < 5; i++)
	{
		printf("%d번째 성적 입력: ", i + 1);
		scanf("%d", &grade[i]);
	}
}

void FindMax(int* score)
{
	maximum = score[0];
	for (int i = 0; i < 5; i++)
	{
		if (score[i] > maximum)
		{
			maximum = score[i];
		}
	}
}

int CountMax(int* score)
{
	int count = 0;
	for (int i = 0; i < 5; i++)
	{
		if (score[i] == maximum)
		{
			count += 1;
		}
	}
	return count;
}

void ShowData(int* score)
{
	for (int i = 0; i < 5; i++)
	{
		printf("%d ", score[i]);
	}
}

int main(void)
{
	InputData();
	ShowData(grade);
	FindMax(grade);
	printf("%d\n", maximum);
	printf("%d", CountMax(grade));

	return 0;
}
728x90
반응형

'Language > C & C++' 카테고리의 다른 글

Visual Studio Short-cut  (0) 2022.11.18
memset Function  (0) 2022.10.28
[TIP] strlen - remove newline  (0) 2022.10.26
[TIP] DO NOT USE fflush function  (0) 2022.10.25
[C] How to Handle String  (0) 2022.10.25

+ Recent posts