Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void toigian(int &x, int &y)
- {
- for (int i = x; i > 0; i--) {
- if (x%i == 0 && y%i == 0) { x = x / i; y = y / i; }
- }
- }
- void main()
- {
- int a[20];
- int b[20];
- int g = 0;
- for (int i = 2; i <= 7; i++) {
- for (int j = 1; j < i; j++) {
- int x = j;
- int y = i;
- toigian(x, y);
- if (y != i)continue;
- a[g] = x;
- b[g] = y;
- g++;
- }
- }
- int n = g-1;
- int m = g;
- for (int j = 0; j < m; j++) {
- for (int i = 0; i < g; i++) { //tim gia tri lon nhat de hoan gia tri voi a[n],b[n] sau do giam n 1 don vi
- int x, y;
- if (a[i] * b[n]>a[n] * b[i]) {
- x = a[i];
- y = b[i];
- a[i] = a[n];
- b[i] = b[n];
- a[n] = x;
- b[n] = y;
- }
- }
- n--;
- g--;
- }
- for (int i = 0; i < m; i++) {
- printf("%i / %i\t", a[i], b[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement