Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <math.h>
- using namespace std;
- int main(){
- cout << "這是DC-porg4,請選擇你要執行的項目:"<<endl;
- int a;
- cin >> a;
- if (a != 1 && a != 0){
- cout << "重新輸入";
- }
- while (a==1||a==0){
- while (a==1){
- int de,ba,de1,k,m = 0;
- int n1=1,n2=1,n3,n4,n5,n7;
- cout << "輸入深度:" <<endl;
- cin >> de;
- cout << "輸入球數:" <<endl;
- cin >> ba;
- while (de != 0 && ba != 0){
- k = pow(2,de);
- int n0[k];
- int n6[k] = {0};
- n7 = k;
- for (int i = 0; i < k; i++){
- n0[i] = 0;
- }
- int i = 1; //設定i的初值 計算球數量
- while (i <= ba){ //當i<=球的數量
- n1 = 1; //n0陣列的計算
- n2 = 1; //深度計算
- while (n2 < de){ //當n2<=深度
- if (n0[n1] == 0){ //判斷n0中的n1陣列是否為0
- n0[n1] = 1;
- n1 *= 2;
- n6[n2] = n1;
- n2++;
- }
- else if (n0[n1] == 1){ //判斷n0中的n1陣列是否為1
- n0[n1] = 0;
- n1 *= 2;
- n1 += 1;
- n6[n2] = n1;
- n2++;
- }
- }
- i++;
- }
- cout << "1";
- for (int w = 1;w < de ;w++){
- cout << "->";
- cout << n6[w];
- }
- system("PAUSE");
- return 0;
- }
- }
- while (a==0){
- goto END;
- }
- }
- END:
- cout << "";
- }
Add Comment
Please, Sign In to add comment