Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int fn(int arr[30],int);
- int main(void){
- int arr[30],n=30;
- for(int i=0;i<n;i++){
- if(i%2==0){
- arr[i]=i;
- }else{
- arr[i]=n-i;
- }
- }
- for(int i=0;i<n;i++){
- printf("%d ", arr[i]);
- }
- printf("\n");
- printf("%d\n", fn(arr,n));
- return(0);
- }
- int fn(int arr[30],int n){
- for(int i=n-1;i>0;i--){
- for(int j=0;j<n;j++){
- if(arr[j]<arr[j+1]){
- int tmp=arr[j];
- arr[j]=arr[j+1];
- arr[j+1]=tmp;
- }
- }
- }
- for(int i=0;i<n;i++){
- printf("%d ", arr[i]);
- }
- printf("\n");
- int p,t=0;
- p=arr[0];
- for(int i=0;i<n;i++){
- if(arr[i]<p && t<9){
- p=arr[i];
- t++;
- }
- }
- return(p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement