Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tinh tong binh phuong cac so am trong mang
- // Khai bao thu vien neus cos
- #include<stdio.h>
- #include<conio.h>
- #define SIZE 100
- void nhap(int A[],int &n);
- long tongbinh(int A[],int n);
- void main()
- {
- int A[SIZE],n;
- nhap(A,n);
- printf("%ld",tongbinh(A,n));
- }
- void nhap(int A[],int &n)
- {
- scanf("%d",&n);
- for(int i=0;i<n;i++)
- {
- scanf("%d",&A[i]);
- }
- }
- long tongbinh(int A[],int n)
- {
- long s=0;
- for(int i=0;i<n;i++)
- {
- if(A[i]<0)
- {
- s=s+ (A[i]*A[i]);
- }
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement