- 949 名前:デフォルトの名無しさん mailto:sage [2007/07/26(木) 02:35:07 ]
- >>944
よりによってfloatか.微妙な誤差が出るかも 記法はwikiにならった #include <iostream> using namespace std; int main() { float A, B; cout << "input numerator (A in A/B)" << endl; cin >> A; cout << "input denominator (B in A/B)" << endl; cin >> B; if (A == 0) { cout << 0 << endl; } else if (B == 0) { cout << "error" << endl; } else { cout << "[" << (int)(A/B) << "; "; A = A-(int)(A/B)*B; while (A != 1) { if (B-(int)(B/A)*A == 0) { B /= A; break; } cout << (int)(B/A) << ", "; float w = A; A = B-(int)(B/A)*A; B = w; } cout << (int)B << "]" << endl; } }
|

|