Advertisement
Guest User

C

a guest
Jan 28th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "conio.h"
  3. main()
  4. {
  5. int i,n,vtmax,vtmin;
  6. float a[100],max,min;
  7. printf("Nhap so phan tu cua day so: ");
  8. scanf("%d",&n);
  9. if (n>0)
  10. {
  11. for (i=0;i<n;i++)
  12. {
  13. printf("\nNhap phan tu thu a[%d]: ",i);
  14. scanf("%f",&a[i]);
  15. }
  16. max = a[0];
  17. min = a[0];
  18. for (i=0;i<n;i++)
  19. {
  20. if (max < a[i]) max = a[i];
  21. if (min > a[i]) min = a[i];
  22. }
  23. printf("\nSo lon nhat trong day la: %f, o vi tri ",max);
  24. for (i=0;i<n;i++)
  25. if (a[i] == max) printf("%4d",i);
  26. printf("\nSo nho nhat trong day la: %f, o vi tri ",min);
  27. for (i=0;i<n;i++)
  28. if (a[i] == min) printf("%4d",i);
  29. }
  30. else printf("Ban phai nhap so nguyen duong!");
  31. getch();
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement