标签:sizeof color col nbsp ring open img pen name
扩充到任意的m和n.
#include<iostream> #include<cstdio> #include<string> #include<string.h> using namespace std; int main() { int m, n; cin >> m >> n; int yu[15], xiao[600]; memset(yu,0,sizeof(yu)); if (m < 0 && n>0) { cout << "-"; m = -m; } else if (m > 0 && n < 0) { cout << "-"; n = -n; } int k = m % n; if(k==0) cout << m / n << endl; else { cout<<m/n<< "."; int cnt = 0; yu[k] = 1; while (k) { k = k * 10; xiao[++cnt] = k / n; k %= n; if (yu[k] == 1) break; yu[k] = 1; } for (int i = 1; i <= cnt; i++) cout << xiao[i]; cout << endl; } return 0; }
标签:sizeof color col nbsp ring open img pen name
原文地址:https://www.cnblogs.com/Kaike/p/9865551.html