// UVa 834 - Continued Fractions
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
vector<int> v;
int a, b;
while (cin >> a >> b) {
v.clear();
do {
v.push_back(a / b);
int c = a % b;
a = b;
b = c;
} while (b != 0);
cout << "[" << v[0] << ";";
for (int i = 1; i + 1 < v.size(); i++)
cout << v[i] << ",";
cout << v[v.size() - 1] << "]\n";
}
return 0;
}
No comments:
Post a Comment