Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- float aff[50][50], n, m, last[2], total;
- float a = 0, b = 0, c = 0, d = 0, x = 0, y = 0, t = 0;
- int lin, col;
- scanf("%f%f", &n, &m);
- while(n != 0 && m != 0)
- {
- a = 0;
- b = 0;
- c = 0;
- d = 0;
- x = 0;
- y = 0;
- t = 0;
- for(lin = 0; lin < n; lin++)
- {
- last[0] = n;
- last[1] = m;
- while(last[0] > 0)
- {
- last[0]--;
- last[1]--;
- }
- aff[0][0] = 1;
- for(col = 0; col < m; col++)
- {
- t += aff[lin][col];
- if(col == 0)
- {
- a += aff[lin][col];
- }
- if(col == m)
- {
- b += aff[lin][col];
- }
- if(lin == 0)
- {
- c += aff[lin][col];
- }
- if(lin == n)
- {
- d += aff[lin][col];
- }
- if(lin == col)
- {
- x += aff[lin][col];
- }
- if(lin == last[0] && col == last[1])
- {
- y += aff[lin][col];
- }
- aff[lin][col]++;
- }
- }
- total = (t - (x + y) + (a * b) - (c * d) ) / (n * m);
- printf("%f %f %f %f %f %f %f\n", a, b, c, d, x, y, t);
- printf("%.2f\n", total);
- scanf("%f%f", &n, &m);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement