MapleStory Finger Point

๐Ÿ”ต C,C++,C#/๐Ÿ“šCore C_Programming

[C/Core C Programming] Chapter7

HYEJU01 2023. 3. 27. 19:19
//2
#include <stdio.h>
#include <math.h>

int main() {

	double a;
		double r;
		double n[10] = { 0, };

	printf("์ฒซ๋ฒˆ์งธํ•ญ?");
	scanf_s("%lf", &a);

	printf("๊ณต๋น„?");
	scanf_s("%lf", &r);


	printf("๋“ฑ๋น„์ˆ˜์—ด");
	for (int i =1; i < 10; i++) {
		n[0] = a;

		n[i] = n[i-1]* r;
	}
	for (int j = 0; j < 10; j++) {
		printf("%.1lf   ", n[j]);
	}
	return 0;

}
//3
#include <stdio.h>
#include <math.h>

int main() {

	int n[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int i;
	int max = 0, min = 0;

	printf("๋ฐฐ์—ด?");
	for (i = 0; i < 10; i++) {
		printf("%d ",n[i]);
	}


	for (i = 0; i < 10; i++) {

		max = n[0];
		if (max < n[i])
			max = n[i];
	}
	printf("์ตœ๋Œ€๊ฐ’? : %d\n", max);


	for (i = 0; i < 10; i++) {

		min = n[0];
		if (min > n[i])
			min = n[i];
	}
	printf("์ตœ์†Œ๊ฐ’? : %d\n", min);

	return 0;

}
//12
#include <stdio.h>


int main() {

	int n[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int i;
	int a;
	int num = 0;

	printf("๋ฐฐ์—ด?\n");
	for (i = 0; i < 10; i++)
	{
		printf("%d ", n[i]);

	}
	printf("\n");
	printf("์ฐพ์„ ๊ฐ’?\n");
	scanf_s("%d", &a);
	
	for (i = 0; i < 10; i++) {

		if (a == n[i - 1])
		{
			num = i-1;

			printf("%d ๋Š” %d ๋ฒˆ์งธ ์›์†Œ์ž…๋‹ˆ๋‹ค.\n", a, num);
			break;

		}

	}
	if (!(a == n[i - 1]))
	{
		printf("๊ฐ™์€ ๊ฐ’์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.\n");
	}

	

	return 0;
}
//7

#include <stdio.h>
#define size 10

void fill_array(int arr[], int a, int n);

int main() {

	int n;
	int arr[size] = { 0, };

	printf("๋ฐฐ์—ด์˜ ์›์†Œ์— ์ €์žฅํ•  ๊ฐ’?");
	scanf_s("%d", &n);

	fill_array(arr,size,n);
		
	
	return 0;
}


void fill_array(int arr[], int a, int b) {

	int i;

	for (i = 0; i < a; i++) {
		arr[i] = b;
		printf("%d",arr[i]);
	}
	
	
}
//8
#include <stdio.h>


int main() {
	int n[5] = { 0, };
	int s[5] = { 0, };
	int i,a=0;

	printf("์ƒํ’ˆ๊ฐ€ 5๊ฐœ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:");

	for (i = 0; i < 5; i++) {
		scanf_s("%d", &n[i]);
	}

	printf("ํ• ์ธ์œจ?");
	scanf_s("%d", &a);

	for (i = 0; i < 5; i++) {

		s[i] = n[i] - (n[i] * a / 100);

		printf("๊ฐ€๊ฒฉ : %d    ---->  ํ• ์ธ๊ฐ€:   %d\n",n[i],s[i]);

	}

	return 0;
}

//11
#include <stdio.h>
#define ROW 5
#define COL 4

int main() {
	int sum[ROW] = { 0, };
	int student[ROW][COL] = { { 28,28,26,9 }, { 30,27,30,10 }, { 25,26,24,8 }, { 18,22,22,5 }, { 24,25,30,10 } };
	double sum_2[COL] = { 0 ,};
	double avg[COL] = { 0 , };
	for (int i = 0; i < ROW; i++) {
		printf("ํ•™ ์ƒ %d ๋ฒˆ  :  ", i+1);

		for (int j = 0; j < COL; j++) {
			sum[i] += student[i][j];
		printf("%d ", student[i][j] );
		
		}

		printf("==> %d", sum[i]);
		printf("\n");
	}

	printf("ํ•ญ๋ชฉ๋ณ„ ํ‰๊ท  :");


	for (int i = 0; i < COL; i++) {
		for (int j = 0; j < ROW; j++) {
		sum_2[i] += student[j][i];
		avg[i] = sum_2[i] / ROW;
		}
		printf("%.2f ", avg[i]);
	}
	
	return 0;
}