Advertisement
MarkUa

Untitled

Sep 14th, 2019
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <stdio.h>
  5. float arr[10];
  6. void enter_numbers(int position) {
  7.     if (position == 10)
  8.         return;
  9.     else {
  10.         printf("enter %d number :", position);
  11.         scanf_s("%f", &arr[position]);
  12.         getchar();
  13.         return enter_numbers(++position);
  14.     }
  15. }
  16. int minimal_number_position(int position, int step) {
  17.     if (step == 10) {
  18.         return position;
  19.     }
  20.     else {
  21.         if (arr[step] > arr[position]) {
  22.             position = step;
  23.             return  minimal_number_position(position, ++step);
  24.         }
  25.         else {
  26.             return  minimal_number_position(position, ++step);
  27.         }
  28.     }
  29.  
  30. }
  31. void print_numbers(int pos) {
  32.     if (pos == 10) {
  33.         return;
  34.  
  35.     }
  36.     else {
  37.         printf("%d . %.2f\n", pos, arr[pos]);
  38.         return print_numbers(++pos);
  39.     }
  40. }
  41. int main()
  42. {
  43.     enter_numbers(0);
  44.     print_numbers(0);
  45.     printf("minimal number position %d",minimal_number_position(0,0));
  46.     getchar();
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement