阅读程序:
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 | #include<iostream> using namespace std; int x,y,n,m; int a[1000]; string num="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void change(int i,int j){ a[i]^=a[j]; a[j]^=a[i]; a[i]^=a[j]; } int main (){ cin >> x >> y; m=(1<<y)-1; while(x!=0){ n++; a[n]=(x&m); x=(x>>y); } for(int i=1;i<=n/2;i++){ change(i,n-i+1); } for(int i=1;i<=n;i++){ cout << num[a[i]]; } return 0; } |
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、将第4行接在第10行之后,程序会出现编译错误。
2、输入的y绝对值在1000以内,程序都能正确运行。
3、将程序第20行换成 change(n-i+1,i);不会影响程序结果。
4、输入 37 1 输出结果长度大于5。
5、输入37 3,输出的结果为 ( )
6、输入335 4,输出的结果为 ( )