2000_1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <iostream> #include <cstdio> #include <cmath> using namespace std; int b[105],c[105]; bool p1; int main(){ int i,j,j1,j2,p,q; cin>>q>>p;j=1;p1=true;b[j]=q;j1=0; while (q>0&&p1){ j1++; c[j1]=q*10/p; q=q*10-c[j1]*p; if(q>0){ j2=1; while(b[j2]!=q&&j2<=j)j2++; if (b[j2]==q){ p1=false;cout<<"0."; for (int i = 1; i <=j2-1; i++)cout<<c[i]; cout<<'{'; for (i =j2; i<=j1; i++)cout<<c[i]; cout<<'}'; } else{j++,b[j]=q;} } if(q==0){ cout<<"0."; for ( i = 1; i <=j1 ; i++)cout<<c[i]; cout<<endl; } } } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、输入的q可以为任意自然数( )
2、输入-1 2,会输出-0.5 ( )
3、输入1 2时,程序会输出0.{5} ( )
4、输入的q,p为小于10^4的自然数时,程序可能会运行错误( )
5、输入5 13,输出为( )
6、删去下列哪一行后,输出结果一定错误的是( )