Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. void nhap(double **arr,int dong,int cot)
  4. {
  5. for(int i=0;i<dong;i++)
  6. {
  7. for(int j=0;j<cot;j++)
  8. {
  9. scanf("%lf",*(arr+i)+j);
  10. }
  11. }
  12. }
  13. double tong(double **arr,int dong,int cot,int kt)
  14. {
  15. double sum=0;
  16. for(int i=0;i<dong;i++)
  17. {
  18. if(i+1==kt)
  19. {
  20. for(int j=0;j<cot;j++)
  21. {
  22. sum+=*(*(arr+i)+j);
  23. }
  24. break;
  25. }
  26.  
  27.  
  28. }
  29. return sum;
  30. }
  31. int main()
  32. {
  33. int dong,cot;
  34. scanf("%d%d",&dong,&cot);
  35. double **arr=(double **)calloc(dong,sizeof(double*));
  36. for(int i=0;i<dong;i++)
  37. {
  38. *(arr+i)=(double *)calloc(cot,sizeof(double));
  39. }
  40. nhap(arr,dong,cot);
  41. int kt;
  42. scanf("%d",&kt);
  43. printf("%.2lf",tong(arr,dong,cot,kt));
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement