Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Xoa tat ca cac so lon nhat mang so thuc
- // Khai bao cac ham thu vien neu co
- #include<stdio.h>
- #include<conio.h>
- #define SIZE 100
- void nhap(float a[],int &n)
- {
- scanf("%d",&n);
- float x;
- for(int i=0;i<n;i++)
- {
- scanf("%f",&x);
- a[i]=x;
- }
- }
- float timMax(float a[],int n)
- {
- float max=a[0];
- for(int i=0;i<n;i++)
- {
- if(a[i]>max)
- {
- max=a[i];
- }
- }
- return max;
- }
- void xoaPT(float a[],int &n,int k)
- {
- // k la vi tri can xoa
- for(int i=k;i<n;i++)
- {
- a[i]=a[i+1];
- }
- n--;
- }
- void xoalonnhat(float a[],int &n)
- {
- float soMax=timMax(a,n);
- for(int i=0;i<n;i++)
- {
- if(a[i]==soMax)
- {
- xoaPT(a,n,i);
- i--;
- }
- }
- }
- void xuat(float a[],int n)
- {
- for(int i=0;i<n;i++)
- {
- printf("%.2f",a[i]);
- }
- }
- void main()
- {
- float a[SIZE];
- int n;
- nhap(a,n);
- xoalonnhat(a,n);
- xuat(a,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement