第三章习题

来源:互联网 发布:如何评价涛哥 知乎 编辑:程序博客网 时间:2024/05/24 22:45

1.源代码如下:

#include "stdafx.h"

#include <iostream>

using namespace std;
int main()
{
int num, n;
cout << "please input a number:" << endl;
cin >> num;
cout << "please input n:" << endl;
cin >> n;
int y, top, S[10];
top = -1;
while (num != 0)
{
y = num%n;
S[++top] = y;
num = num / n;
}
while (top != -1)
cout << S[top--];
cout << endl;

}

2.运行结果如下:



原创粉丝点击