Guest User

Untitled

a guest
Oct 22nd, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void mini_max(char *min,char *max,char *str)
  6. {
  7.     int i=0;
  8.     if(str[i]!='\0')
  9.     {
  10.         if(*min > str[i]) min = str[i];
  11.         if(*max =< str[i]) max = str[i];
  12.     i++;
  13.         mini_max(&min,&max,char *(str+i);
  14.     }
  15. }
  16.  
  17. int main(void)
  18. {
  19.     char str[10]="\0";
  20.     unsigned int i;
  21.     for(i=0;i<10;i++)
  22.         str[i]='a' + rand() % ('z' - 'a');
  23.     printf("%s \n", str); //wypisz zawartość łancucha str
  24.     char min=str[0], max=str[9];
  25.     mini_max(&min,&max,str);
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment