Advertisement
nguyenhappy92

Tìm giá trị âm lớn nhất trong ma trận

Dec 20th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. int amdau(int a[][SIZE],int m,int n)
  2. {
  3. for(int i=0;i<m;i++)
  4. {
  5. for(int j=0;j<n;j++)
  6. {
  7. if(a[i][j]<0)
  8. return a[i][j];
  9. }
  10. }
  11. return 0;
  12. }
  13. int ammax(int a[][SIZE],int m,int n)
  14. {
  15. int max=amdau(a,m,n);
  16. if(max==0)
  17. {
  18. return 0;
  19. }
  20. else
  21. {
  22. for(int i=0;i<m;i++)
  23. {
  24. for(int j=0;j<n;j++)
  25. {
  26. if(((a[i][j])<0)&&(a[i][j]>max))
  27. {
  28. max=a[i][j];
  29. }
  30. }
  31. }
  32. }
  33. return max;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement