반응형
jungol 171부터 jungol 180까지의c언어로 작성된 코드입니다.
참고해 주시면 좋을 것 같습니다.
jungol 171
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int j_171_1(int n)
{
int answer;
answer = 0;
for (int i = 1; i <= n; i++)
{
answer += i;
}
return answer;
}
int main(void)
{
int n;
scanf("%d", &n);
printf("%d", j_171_1(n));
return 0;
}
jungol 172
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void j_172_1(int n)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
printf("%d ", i * j);
}
printf("\n");
}
}
int main(void)
{
int n;
scanf("%d", &n);
j_172_1(n);
return 0;
}
jungol 173
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
int j_173_1(int a, int b)
{
a *= a;
b *= b;
return abs(a - b);
}
int main(void)
{
int a;
int b;
scanf("%d %d", &a, &b);
printf("%d", j_173_1(a, b));
return 0;
}
jungol 174
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void j_174_1(int arr[5])
{
scanf("%d %d %d", &arr[0], &arr[1], &arr[2]);
arr[3] = arr[0] + arr[1] + arr[2];
}
void j_174_2(int arr[5])
{
for (int i = 0; i < 4; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
int main(void)
{
int arr[5] = { 0, };
int arr1[5] = { 0, };
int arr2[5] = { 0, };
int arr3[5] = { 0, };
j_174_1(arr1);
j_174_1(arr2);
j_174_1(arr3);
arr[0] = arr1[0] + arr2[0] + arr3[0];
arr[1] = arr1[1] + arr2[1] + arr3[1];
arr[2] = arr1[2] + arr2[2] + arr3[2];
arr[3] = arr1[3] + arr2[3] + arr3[3];
j_174_2(arr1);
j_174_2(arr2);
j_174_2(arr3);
j_174_2(arr);
return 0;
}
jungol 175
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void j_175_1(int arr[15], int n)
{
int temp;
for (int i = 0; i < n; i++)
{
for (int j = i; j < n; j++)
{
if (arr[i] < arr[j])
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
printf("%d ", arr[i]);
}
}
int main(void)
{
int n;
int arr[15] = { 0, };
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
j_175_1(arr, n);
return 0;
}
jungol 176
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int j_176_1(double a, double b)
{
int count;
count = 0;
for (double i = ceil(sqrt(a)); i <= floor(sqrt(b)); i++)
{
count++;
}
return count;
}
int main(void)
{
double a;
double b;
scanf("%lf %lf", &a, &b);
if (a < b)
{
printf("%d", j_176_1(a, b));
}
else
{
printf("%d", j_176_1(b, a));
}
return 0;
}
jungol 177
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int j_177_1(int arr[5])
{
int sum = 0;
for (int i = 0; i < 5; i++)
{
sum += abs(arr[i]);
}
return sum;
}
int main(void)
{
int arr[5] = {0,};
for (int i = 0; i < 5; i++)
{
scanf("%d", &arr[i]);
}
printf("%d\n", j_177_1(arr));
return 0;
}
jungol 178
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int j_178_1(int n)
{
return pow(2, n);
}
int main(void)
{
int n;
scanf("%d", &n);
printf("%d\n", j_178_1(n));
return 0;
}
jungol 179
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
void j_179_1(double arr[3])
{
float sum;
sum = 0.0;
for (int i = 0; i < 3; i++)
{
sum += arr[i];
}
printf("%.0f\n", sum / 3);
sum = 0;
for (int i = 0; i < 3; i++)
{
sum += round(arr[i]);
}
printf("%.0f\n", sum / 3);
}
int main(void)
{
double arr[3];
for (int i = 0; i < 3; i++)
{
scanf("%lf", &arr[i]);
}
j_179_1(arr);
return 0;
}
jungol 180
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#define A 7
void j_180_1(int arr[A])
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < A - 1; j++)
{
if (arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for (int i = 0; i < A; i++)
{
printf("%d ", arr[i]);
}
}
int main(void)
{
int arr[A] = { 0, };
for (int i = 0; i < A; i++)
{
scanf("%d", &arr[i]);
}
j_180_1(arr);
return 0;
}
반응형
'Algorithm > JUNGOL' 카테고리의 다른 글
C언어, JUNGOL 581 ~ 590 (1) | 2023.11.24 |
---|---|
C언어, JUNGOL 9081 ~ 9090 (1) | 2023.11.23 |
C언어, JUNGOL 571 ~ 580 (2) | 2023.11.21 |
C언어, JUNGOL 9071 ~ 9080 (2) | 2023.11.20 |
C언어, JUNGOL 161 ~ 170 (0) | 2023.11.19 |