본문 바로가기
Algorithm/JUNGOL

C언어, JUNGOL 611 ~ 620

by OdOp 관리자 2023. 12. 31.
반응형

jungol 611부터 jungol 620까지 c언어로 작성된 코드입니다.

참고해 주시면 좋을 것 같습니다. 

 

jungol 611

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char	c1[20];
	int	num1;
	float	num2;

	scanf("%s", c1);
	num1 = atoi(c1);
	printf("%d\n", num1 * 2);
	num2 = atof(c1);
	printf("%.2f\n", num2);
	return 0;
}

 

jungol 612

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main()
{
	int	arr[5];
	char	c1[50];

	scanf("%d %d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3], &arr[4]);
	sprintf(c1, "%d%d%d%d%d", arr[0], arr[1], arr[2], arr[3], arr[4]);
	for (int i = 0; i < strlen(c1); i++)
	{
		printf("%c", c1[i]);
		if ((i + 1) % 3 == 0)
			printf("\n");
	}
	return 0;
}

 

jungol 613

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct Person {
    char name[20];
    char school[20];
    int cls;
};

int main(void)
{
    char	name[20];
    char	school[20];
    int	cls;
    struct Person	p1;

    scanf("%s %s %d", name, school, &cls);
    strcpy(p1.name, name);
    strcpy(p1.school, school);
    p1.cls = cls;
    printf("Name : %s\nSchool : %s\nGrade : %d\n", p1.name, p1.school, p1.cls);
    return 0;
}

 

jungol 614

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct Person
{
    char school[20];
    int grade;
};

int main(void)
{
    struct Person	p1;
    struct Person	p2;
    char	school[20];
    int	grade;

    p1 = { "Jejuelementary", 6 };
    scanf("%s %d", school, &grade);
    strcpy(p2.school, school);
    p2.grade = grade;
    printf("%d grade in %s School\n", p1.grade, p1.school);
    printf("%d grade in %s School\n", p2.grade, p2.school);
    return 0;
}

 

jungol 615

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct Person
{
    char name[20];
    int Korean;
    int English;
};

int main(void)
{
    struct Person   p1;
    struct Person   p2;
    char    name[20];
    int Korean, English;
    float   K_avg, E_avg;

    scanf("%s %d %d", name, &Korean, &English);
    strcpy(p1.name, name);
    p1.Korean = Korean;
    p1.English = English;
    scanf("%s %d %d", name, &Korean, &English);
    strcpy(p2.name, name);
    p2.Korean = Korean;
    p2.English = English;
    K_avg = (p1.Korean + p2.Korean) / 2;
    E_avg = (p1.English + p2.English) / 2;
    printf("%s %d %d\n", p1.name, p1.Korean, p1.English);
    printf("%s %d %d\n", p2.name, p2.Korean, p2.English);
    printf("avg %.0f %.0f\n", K_avg, E_avg);
    return 0;
}

 

jungol 616

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

struct axis
{
    int x;
    int y;
};

int main(void)
{
    struct axis s1, s2, s3;

    scanf("%d %d %d %d %d %d", &s1.x, &s1.y, &s2.x, &s2.y, &s3.x, &s3.y);
    printf("(%.1f, %.1f)\n", ((float)s1.x + s2.x + s3.x) / 3, ((float)s1.y + s2.y + s3.y) / 3);
    return 0;
}

 

jungol 617

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

struct Person {
    char name[20];
    int height;
};

int main(void)
{
    struct Person p[5];
    int person, height = 20000;

    for (int i = 0; i < 5; i++)
    {
        scanf("%s %d", p[i].name, &p[i].height);
        if (height >= p[i].height) 
        {
            height = p[i].height;
            person = i;
        }
    }
    printf("%s %d\n", p[person].name, height);
    return 0;
}

 

jungol 618

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct Person
{
    char name[20];
    int height;
    float weight;
};

int main(void)
{
    struct Person p[5];

    for (int i = 0; i < 5; i++)
    {
        scanf("%s %d %f", p[i].name, &p[i].height, &p[i].weight);
    }
    printf("name\n");
    for (int i = 0; i < 5; i++)
    {
        for (int j = i; j < 5; j++) 
        {
            if (strcmp(p[i].name, p[j].name) > 0)
            {
                struct Person tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
    for (int i = 0; i < 5; i++)
    {
        printf("%s %d %.1f\n", p[i].name, p[i].height, p[i].weight);
    }
    printf("weight\n");
    for (int i = 0; i < 5; i++)
    {
        for (int j = i; j < 5; j++)
        {
            if (p[i].weight < p[j].weight)
            {
                struct Person tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }
    for (int i = 0; i < 5; i++)
    {
        printf("%s %d %.1f\n", p[i].name, p[i].height, p[i].weight);
    }
    return 0;
}

 

jungol 619

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
    int a;
    int* p = &a;

    scanf("%d", p);
    printf("%p %d", p, a);
    return 0;
}

 

jungol 620

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
    int a;
    int* p = &a;

    scanf("%d", p);
    printf("%d...%d\n", a / 10, *p % 10);
    return 0;
}
반응형

'Algorithm > JUNGOL' 카테고리의 다른 글

C언어, JUNGOL 9111 ~ 9120  (0) 2024.01.16
C언어, JUNGOL 201 ~ 210  (0) 2023.12.01
C언어, JUNGOL 601 ~ 610  (2) 2023.11.30
C언어, JUNGOL 9101 ~ 9110  (0) 2023.11.29
C언어, JUNGOL 191 ~ 200  (2) 2023.11.28