반응형
jungol 201부터 jungol 210까지 c언어로 작성된 코드입니다.
참고해 주시면 좋을 것 같습니다.
jungol 201
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int n1;
int* ptr = &n1;
scanf("%d", ptr);
for (int i = 0; i < *ptr; i++)
{
printf("*");
}
return 0;
}
jungol 202
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
int* ptr1;
int* ptr2;
int *ptr3;
ptr1 = (int*)malloc(sizeof(int)*1);
ptr2 = (int*)malloc(sizeof(int) * 1);
ptr3 = (int*)malloc(sizeof(int) * 1);
scanf("%d %d", ptr1, ptr2);
printf("%d\n", abs(*ptr1-*ptr2));
return 0;
}
jungol 203
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int* ptr1;
int odd;
int even;
ptr1 = (int*)malloc(sizeof(int) * 10);
odd = 0;
even = 0;
for (int i = 0; i < 10; i++)
{
scanf("%d", ptr1 + i);
}
for (int i = 0; i < 10; i++)
{
if (*(ptr1 + i) % 2 == 0)
{
even++;
}
else
{
odd++;
}
}
printf("odd : %d\neven : %d\n", odd, even);
free(ptr1);
return 0;
}
jungol 204
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int n;
int* ptr1;
int min;
int max;
ptr1 = (int*)malloc(sizeof(int) * n);
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", ptr1 + i);
}
min = *(ptr1 + 1);
max = *(ptr1 + 2);
for (int i = 0; i < n; i++)
{
if (min > *(ptr1 + i))
min = *(ptr1 + i);
if (max < *(ptr1 + i))
max = *(ptr1 + i);
}
printf("max : %d\nmin : %d\n", max, min);
free(ptr1);
return 0;
}
jungol 205
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void)
{
float num1;
float num2;
scanf("%f %f", &num1, &num2);
printf("%.2f %.2f %.2f\n", round(num1 * 100) / 100, round(num2 * 100) / 100, round((num1 + num2) * 100) / 100);
return 0;
}
jungol 206
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int num1;
int num2;
int num3;
int sum;
scanf("%d %d %d", &num1, &num2, &num3);
sum = num1 + num2 + num3;
printf("%d %d...%d\n", sum, sum / 3, sum % 3);
return 0;
}
jungol 207
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int num1;
int num2;
char oper;
int answer;
scanf("%d %d %c", &num1, &num2, &oper);
switch (oper)
{
case '+':
answer = num1 + num2;
break;
case '-':
answer = num1 - num2;
break;
case '*':
answer = num1 * num2;
break;
case '/':
answer = num1 / num2;
break;
case '%':
answer = num1 % num2;
break;
}
printf("%d %c %d = %d\n", num1, oper, num2, answer);
return 0;
}
jungol 208
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int num;
int answer;
answer = 1;
scanf("%d", &num);
while (num > 1)
{
answer *= num;
num--;
}
printf("%d\n", answer);
return 0;
}
jungol 209
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int count;
int num;
count = 0;
while (1)
{
scanf("%d", &num);
if (num == 0)
break;
else if (num % 15 == 0)
{
count++;
printf("%d ", num);
}
}
printf("\n%d\n", count);
return 0;
}
jungol 210
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int num;
int len;
int star;
int j;
scanf("%d", &num);
len = num * 2 - 1;
for (int i = 1; i <= num; i++)
{
star = 2 * i - 1;
for (j = 0; j < len - star; j++)
{
printf(" ");
}
for (j = 0; j < star; j++)
{
printf("* ");
}
printf("\n");
}
for (int i = num - 1; i >= 1; i--)
{
star = 2 * i - 1;
for (j = 0; j < len - star; j++)
{
printf(" ");
}
for (j = 0; j < star; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
반응형
'Algorithm > JUNGOL' 카테고리의 다른 글
C언어, JUNGOL 9111 ~ 9120 (0) | 2024.01.16 |
---|---|
C언어, JUNGOL 611 ~ 620 (2) | 2023.12.31 |
C언어, JUNGOL 601 ~ 610 (2) | 2023.11.30 |
C언어, JUNGOL 9101 ~ 9110 (0) | 2023.11.29 |
C언어, JUNGOL 191 ~ 200 (2) | 2023.11.28 |