谁能帮我看看错在哪了?
Write a C program that reads in 15 integer numbers from the keyboard to anarray (2p). Print out the largest negative number of the array (2p). Write and
use your own function to decide whether a number is negative or not (2p).
Example run:
Give a number please... -2
Give a number please... 5
Give a number please... -7
Give a number please... 3
...
Give a number please... 4
The number with the largest abs value: -2
****************************************************
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int isnegative(int ar[5]){
int i;
for(i=0;i<5;i++)
if(ar[i]<0);
}
int main(int argc, char *argv[]) {
int ar[5],i,min=0;
for(i=0;i<5;i++){
printf("give me a number ");
scanf("%d",&ar[i]);
}
for(i=0;i<5;i++){
if(ar[i]<0){
if(isnegative(ar[i])>min) min=ar[i];
}
}
printf("%d",min);
return 0;
}