This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

45 lines
954 B
C
Executable File

/*
3.Даны целочисленные переменные А, В и С. Задать их вводом с клавиатуры. Вывести в порядке возрастания. (только оператор условия)
*/
#include <stdio.h>
#include <stdlib.h>
int* getNumbers(int a, int b, int c) {
if (a > b) {
int tmp = a;
a = b;
b = tmp;
}
if (b > c) {
int tmp = b;
b = c;
c = tmp;
}
if (a > b) {
int tmp = a;
a = b;
b = tmp;
}
int *answer = malloc(sizeof(int) * 3);
answer[0] = a;
answer[1] = b;
answer[2] = c;
return answer;
}
int main() {
int a, b, c;
printf("Enter 3 numbers: ");
scanf("%d %d %d", &a, &b, &c);
int *result = getNumbers(a, b ,c);
printf("Sorted: %d %d %d", result[0], result[1], result[2]);
free(result);
return 0;
}