Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "conio.h"
- main()
- {
- int i,n,vtmax,vtmin;
- float a[100],max,min;
- printf("Nhap so phan tu cua day so: ");
- scanf("%d",&n);
- if (n>0)
- {
- for (i=0;i<n;i++)
- {
- printf("\nNhap phan tu thu a[%d]: ",i);
- scanf("%f",&a[i]);
- }
- max = a[0];
- min = a[0];
- for (i=0;i<n;i++)
- {
- if (max < a[i]) max = a[i];
- if (min > a[i]) min = a[i];
- }
- printf("\nSo lon nhat trong day la: %f, o vi tri ",max);
- for (i=0;i<n;i++)
- if (a[i] == max) printf("%4d",i);
- printf("\nSo nho nhat trong day la: %f, o vi tri ",min);
- for (i=0;i<n;i++)
- if (a[i] == min) printf("%4d",i);
- }
- else printf("Ban phai nhap so nguyen duong!");
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement