๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ C Programming/๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ_๊ฐœ์ • 3ํŒ

[๋ˆ„๊ตฌ๋‚˜ ์‰ฝ๊ฒŒ ์ฆ๊ธฐ๋Š” C ์–ธ์–ด ์ฝ˜์„œํŠธ - ๊ฐœ์ • 3ํŒ] 7์žฅ Programming ํ’€์ด (1)

by A Lim Han 2023. 1. 15.

# 7์žฅ Programming ํ’€์ด (1)

 

 

289p_1๋ฒˆ)

#include <stdio.h>

int main()
{
	int days[] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

	for (int i = 0; i < 12; i++)
	{
		printf("%d์ผ์€ %d์ผ๊นŒ์ง€ ์žˆ์Šต๋‹ˆ๋‹ค.\n", i + 1, days[i]);
	}

	return 0;
}

 

 

 

 

289p_2๋ฒˆ)

#include <stdio.h>

int main()
{
	int num;
	int array[] = { 0,0,0,0,0,0 };

	printf("์ž…๋ ฅํ•  ์ •์ˆ˜์˜ ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &num);

	for (int i = 0; i < num; i++)
	{
		printf("%d๋ฒˆ์งธ ์š”์†Œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ", i);
		scanf_s("%d", &array[i]);
	}

	for (int i = num - 1; i >= 0; i--)
	{
		printf("%d ", array[i]);
	}

	return 0;
}

 

 

 

 

289p_3๋ฒˆ)

#include <stdio.h>

int main()
{
	int num;
	int array[] = { 0,0,0,0,0,0,0,0,0,0 };
	int sum = 0;

	printf("์ž…๋ ฅํ•  ์ •์ˆ˜์˜ ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &num);

	for (int i = 0; i < num; i++)
	{
		printf("%d๋ฒˆ์งธ ์š”์†Œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ", i);
		scanf_s("%d", &array[i]);

		sum += array[i];
	}

	printf("ํ•ฉ: %d", sum);

	return 0;
}

 

 

 

 

290p_4๋ฒˆ)

#include <stdio.h>

int main()
{
	int array[] = { 0,0,0,0,0 };
	int max, min;

	for (int i = 0; i < 5; i++)
	{
		printf("์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค: ");
		scanf_s("%d", &array[i]);
	}

	max = array[0];
	min = array[0];

	for (int a = 1; a < 5; a++)
	{
		if (array[a] > array[a - 1])
		{
			max = array[a];
		}

		if (array[a] < array[a - 1])
		{
			min = array[a];
		}
	}

	printf("์ตœ๋Œ“๊ฐ’: %d, ์ตœ์†Ÿ๊ฐ’: %d", max, min);

	return 0;
}

 

 

 

 

290p_5๋ฒˆ)

#include <stdio.h>

int main()
{
	int score[3][3] = {
		{30,10,11},
		{40,90,32},
		{70,65,56} };

	int sum = 0;

	for (int i = 0; i < 3; i++)
	{
		for (int b = 0; b < 3; b++)
		{
			sum += score[i][b];
		}

		printf("ํ•™๋ฒˆ์ด %d์ธ ํ•™์ƒ์˜ ํ‰๊ท  ์ ์ˆ˜๋Š” %d์ž…๋‹ˆ๋‹ค.\n", i + 1, sum / 3);
	}

	return 0;
}

 

 

 

 

290p_6๋ฒˆ)

#include <stdio.h>

int main()
{
	int array[10][10] = { 0 };
	int i, x;

	for (int i = 0; i < 10; i++)
	{
		for (int x = 0; x < 10; x++)
		{
			array[i][x] = (i + 1) * (x + 1);
		}
	}

	printf("์•Œ๊ณ  ์‹ถ์€ ๊ตฌ๊ตฌ๋‹จ์„ ์ž…๋ ฅํ•˜์‹œ์˜ค(์˜ˆ: 9 3): ");
	scanf_s("%d %d", &i, &x);

	printf("%d X %d = %d", i, x, array[i-1][x-1]);

	return 0;
}

 

 

 

 

291p_7๋ฒˆ)

#include <stdio.h>

int main()
{
	int array1[100][100] = { {0} };
	int array2[100][100] = { {0} };
	int row = 0, col = 0;

	printf("ํ–‰ ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &row);

	printf("์—ด ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &col);

	printf("์ฒซ ๋ฒˆ์งธ ํ–‰๋ ฌ ์ž…๋ ฅ: \n");
	for (int i = 0; i < row; i++)
	{
		for (int k = 0; k < col; k++)
		{
			scanf_s("%d", &array1[i][k]);
		}

	}

	printf("๋‘ ๋ฒˆ์งธ ํ–‰๋ ฌ ์ž…๋ ฅ: \n");
	for (int a = 0; a < row; a++)
	{
		for (int kk = 0; kk < col; kk++)
		{
			scanf_s("%d", &array2[a][kk]);
		}
	}

	printf("\n๊ณฑํ•œ ๊ฒฐ๊ณผ: \n");
	for (int ii = 0; ii < row; ii++)
	{
		for (int k = 0; k < col; k++)
		{
			printf("%d ", array2[ii][k] * array1[ii][k]);
		}

		printf("\n");
	}

	return 0;
}

 

 

 

 

291p_8๋ฒˆ)

#include <stdio.h>

int main()
{
	int array[100][100] = { {0} };
	int new_array[100][100] = { {0} };
	int row = 0, col = 0;

	printf("ํ–‰ ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &row);

	printf("์—ด ๊ฐœ์ˆ˜: ");
	scanf_s("%d", &col);

	printf("ํ–‰๋ ฌ ์ž…๋ ฅ: \n");
	for (int i = 0; i < row; i++)
	{
		for (int k = 0; k < col; k++)
		{
			scanf_s("%d", &array[i][k]);
		}

	}

	printf("\n์ „์น˜ ํ–‰๋ ฌ: \n");
	for (int a = 0; a < row; a++)
	{
		for (int k = 0; k < col; k++)
		{
			new_array[a][k] = array[k][a];
			printf("%d ", new_array[a][k]);
		}

		printf("\n");
	}

	return 0;
}