Advertisement
nguyenhappy92

Tổng giá trị trên 1 dòng ma trận thực

Dec 20th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // Tong tren 1 dong ma tran so thuc
  2. // khai bao ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5. #define SIZE 100
  6. void nhap(float a[][SIZE],int &m,int &n,int &x)
  7. {
  8. scanf("%d%d%d",&m,&n,&x);// x la so dong
  9. for(int i=0;i<m;i++)
  10. {
  11. for(int j=0;j<n;j++)
  12. {
  13. scanf("%f",&a[i][j]);
  14. }
  15. }
  16. }
  17. float tong(float a[][SIZE],int x,int n)
  18. {
  19. float s=0;
  20. for(int i=0;i<n;i++)
  21. {
  22. s=s+a[x][i];
  23. }
  24. return s;
  25. }
  26. void main()
  27. {
  28. float a[SIZE][SIZE];
  29. int m,n,x;
  30. nhap(a,m,n,x);
  31. printf("%.2f",tong(a,x,n));
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement