void conversion (SqStack *pstack,unsigned int N, const unsigned int d){ if( pstack == NULL)//當傳入參數為指針,必須判空 exit(-1); int mod ;//保存mod = N %d while( N != 0){ mod = N %d; stack_push(pstack,&mod);//將mod入棧 N = N /d; } int top = 0;//顯示棧頂元素 printf(將10進制的%d轉為%d進制後為:,N,d); while(!stack_is_empty(pstack)){ stack_pop(pstack,&top); printf(%d,top); } return ; }
2.結果與結論