苍蝇密度.cpp

来自「用于交通流研究的Wolfram模型的程序」· C++ 代码 · 共 37 行

CPP
37
字号
// 苍蝇密度.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream.h>
#include<stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	float x=0;
	for(n=0;n<100;n++)
	{
		cout<<"X("<<n<<")="<<x<<"  ";
		FILE *fp;
		if((fp=fopen("E:\\file.dat","a+"))==NULL)
		{
			cout<<"Can not open this file."<<endl;
			//exit(0);
		}
		fprintf(fp,"%f   ",x);
		fclose(fp);

		x=11-0.01*x*x;
		cout<<"X("<<n+1<<")="<<x<<endl;
		 if((fp=fopen("E:\\file.dat","a+"))==NULL)
		{
			cout<<"Can not open this file."<<endl;
			//exit(0);
		}
		fprintf(fp,"%f\n",x);
		fclose(fp);

	}
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?