Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int* CalculateMinMax(char* buffer,int n);
- int main()
- {
- int n;
- int *resenje;
- char niz[n];
- printf("Unesite koliko zelite brojeva");
- scanf("%d",&n);
- for(int i=0;i<n;i++){
- printf("Unesite broj");
- scanf("%hu",niz+i*sizeof(short));
- }
- resenje=CalculateMinMax(niz,n);
- printf("\nMinimum %hu",*((short*)(resenje+sizeof(short))));
- printf("\nMakasimum %hu",*((short*)resenje));
- return 0;
- }
- int * CalculateMinMax(char* buffer,int n){
- int *resenje=(int*)malloc(sizeof(int));
- *((short*)resenje)= *((short*)buffer);
- *((short*)(resenje+sizeof(short)))= *((short*)buffer);
- for(int i=0;i<n;i++){
- if(*((short*)buffer+i)<*((short*)(resenje+sizeof(short)))){
- *((short*)(resenje+sizeof(short)))=*((short*)buffer+i);
- }else if(*((short*)buffer+i)>*((short*)resenje)){
- *((short*)resenje)=*((short*)buffer+i);
- }
- }
- return resenje;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement