Advertisement
Guest User

nao sei usar isso nao

a guest
Jul 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. float aff[50][50], n, m, last[2], total;
  5. float a = 0, b = 0, c = 0, d = 0, x = 0, y = 0, t = 0;
  6. int lin, col;
  7. scanf("%f%f", &n, &m);
  8. while(n != 0 && m != 0)
  9. {
  10. a = 0;
  11. b = 0;
  12. c = 0;
  13. d = 0;
  14. x = 0;
  15. y = 0;
  16. t = 0;
  17. for(lin = 0; lin < n; lin++)
  18. {
  19. last[0] = n;
  20. last[1] = m;
  21. while(last[0] > 0)
  22. {
  23. last[0]--;
  24. last[1]--;
  25. }
  26. aff[0][0] = 1;
  27. for(col = 0; col < m; col++)
  28. {
  29. t += aff[lin][col];
  30. if(col == 0)
  31. {
  32. a += aff[lin][col];
  33. }
  34. if(col == m)
  35. {
  36. b += aff[lin][col];
  37. }
  38. if(lin == 0)
  39. {
  40. c += aff[lin][col];
  41. }
  42. if(lin == n)
  43. {
  44. d += aff[lin][col];
  45. }
  46. if(lin == col)
  47. {
  48. x += aff[lin][col];
  49. }
  50. if(lin == last[0] && col == last[1])
  51. {
  52. y += aff[lin][col];
  53. }
  54. aff[lin][col]++;
  55. }
  56. }
  57. total = (t - (x + y) + (a * b) - (c * d) ) / (n * m);
  58. printf("%f %f %f %f %f %f %f\n", a, b, c, d, x, y, t);
  59. printf("%.2f\n", total);
  60. scanf("%f%f", &n, &m);
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement