Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tinh gia tri tuyet doi lien sau mang so thuc
- // Khai bao cac ham thu vien neu co
- #include<stdio.h>
- #include<conio.h>
- #include<math.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;
- }
- }
- double tongliensau(float a[],int n)
- {
- double s=0;
- for(int i=0;i<n;i++)
- {
- if(a[i]>fabs(a[i+1]))// gia tri tuyet doi cho so thuc fabs
- {
- s=s+a[i];
- }
- }
- return s;
- }
- void main()
- {
- float a[SIZE];
- int n;
- nhap(a,n);
- printf("%.2lf",tongliensau(a,n));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement