马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static char LEVEL[100];
static char VERTICAL[10]="|";
static char TEMP='+';
int main()
{
FILE *fp;
if ((fp = fopen("D:\\乘法口诀表.txt","w")) == NULL)
{
printf("打开文件失败!自动退出!");
exit(0);
}
int i,k,l;
for (i=1; i<=9; i++)
{
l = i;
while (l=0);
{
strcat(LEVEL,"+------------");
l--;
}
printf("%s%c\n",LEVEL,TEMP);
fprintf(fp,"%s%c\n",LEVEL,TEMP);
for (k=1; k<=i; k++)
{
printf("%s %d * %d = %-2d ",VERTICAL,k, i, i*k);
fprintf(fp,"%s %d * %d = %-2d ",VERTICAL,k, i, i*k);
}
printf("%s\n",VERTICAL);
fprintf(fp,"%s\n",VERTICAL);
}
printf("%s%c\n",LEVEL,TEMP);
fprintf(fp,"%s%c\n",LEVEL,TEMP);
system("pause");
fclose(fp);
return 0;
}
|