char array[8][64],程序为何出错?
要打印如下:
*.
*.*.
*..*..*..
*...*...*...*...
*....*....*....*....*....
*.....*.....*.....*.....*.....*.....
*......*......*......*......*......*......*......
*.......*.......*.......*.......*.......*.......*.......*.......
我用的如下程序实现, 出现问题,提示:exe 遇到问题需要关闭。我们对此引起的不便表示抱歉。不知道什么原因,我打印int型的成功,即定义int array[8][64],"*","."分别用0,1代替,打印成功. 不知道为什么打印"*","."就不行了, 请指教.
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#define N 8
int _tmain(int argc, _TCHAR* argv[])
{
char array[8][64];
for (int i = 0; i < N; i++)
{
array[i][0] ='*';
int j;
for (j = 0; j< i * i ;j++ )
{
if (j%(i+1))
{
array[i][j] = '*';
}
else
array[i][j] ='.';
printf("%s",array[i][j]);
}
printf("\n");
}
return 0;
}