将99乘法表的结果输出到一个文件内保存(文件这块就没听。。。现在郁闷了。帮下忙)
// 99chengfabiao.cpp : Defines the entry point for the console application.
// 文件作用:将99乘法表的结果输出到一个文件内保存
#include "stdafx.h"
#include "iostream.h"
main()
{
int x,y;
for(x=1;x<=9;x++)
for(y=1;y<=9;y++)
cout<<x<<"*"<<y<<"="<<x*y<<endl;
return 0;
}
----------------解决方案--------------------------------------------------------
加 输入到一个文件保存怎么加?
----------------解决方案--------------------------------------------------------
FILE *file;/*定义文件结构体指针*/
file=fopen("filename","w");
for(i=1;i<10;i++){
for(j=1;j<10;j++)
fprintf(fp,"%d ",x*y);
fprintf(fp,"\n");
}
fclose(fp);
[此贴子已经被作者于2007-8-6 1:57:28编辑过]
----------------解决方案--------------------------------------------------------