//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;
}