来看看这个为什么会显示乱码呢?
这个是一个双重递归函数,基本可以实现,但是输出会有乱码,搞不懂了。程序代码:
#include<iostream> const int Len = 66; const int Divs = 6; void subdivide(char ar[], int low, int high, int level); int main() { using namespace std; char ruler[Len]; int i; for ( i = 1; i < Len-2; i++) ruler[i] = ' '; ruler[Len - 1] = '\n'; int max = Len - 2; int min = 0; ruler[min] = ruler[max] = '|'; cout << ruler << endl; for ( i = 1; i <Divs; i++) { subdivide(ruler, min, max, i); cout << ruler << endl; for (int j = 1; j <Len - 2; j++) { ruler[j] = ' '; } } cin.get(); return 0; } void subdivide(char ar[], int low, int high, int level) { if (level == 0) return; int mid = (high + low) / 2; ar[mid] = '|'; subdivide(ar, low, mid, level-1); subdivide(ar, mid, high, level - 1); }
还有这个网站怎么附图??