[问题] Dev C++编码错误讯息

楼主: filexchang (OFDMA)   2014-09-12 12:20:51
现在硕四(中间因病休学两次Q@Q)因此对程式有些生疏
可以请大大们帮我看看吗Orz
以下是我写的论文模拟程式码(关于LTE MTC的)
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<stdlib.h>
#include<time.h>
#include<fstream>
using namespace std;
static int Total_MD= 5000.0;//Total MTC device
static int Total_agent= 100.0;//Total agent
static double p=54;//Total preamble
int back_window=32;///Backoff window
static double HAEQ_P=0.1;//HARQ retransmission probability for Msg. 3 and
Msg. 4
int backoff=20;//Backoff Indicator
struct device{
double UID;// RNTI
int x, y; //coordinates
double phase;// MSG1 MSG2 MSG3 MSG4
double traned_time;//transmitted time
double next_trans;//send MSG1 when count to 0
double success_time;//record success time
int picked_preamble;//record which preamble ue picked
bool agent; //through agent or not
};
struct agent{
int x, y; //coordinates
int contention_time;//record success time
bool selected;
double phase;// MSG1 MSG2 MSG3 MSG4
double traned_time;//transmitted time
double next_trans;//send MSG1 when count to 0
double success_time;//record success time
int picked_preamble;//record which preamble ue picked
};
double Nor (double mu, double sigma) // Normal distribution
{
double U1, U2, W, mult;
static double X1, X2;
static int call = 0;
if (call == 1)
{
call = !call;
return (mu + sigma * (double) X2);
}
do
{
U1 = -1 + ((double) rand () / RAND_MAX) * 2;
U2 = -1 + ((double) rand () / RAND_MAX) * 2;
W = pow (U1, 2) + pow (U2, 2);
}
while (W >= 1 || W == 0);
mult = sqrt ((-2 * log (W)) / W);
X1 = U1 * mult;
X2 = U2 * mult;
call = !call;
return (mu + sigma * (double) X1);
}
int randint(int low, int up)
{
return (int)((rand() / (RAND_MAX+1.0)) * (up - low + 1.0) + low);
}
int main()
{
double success_ratio=0; //MD's RACH success ratio
int count_MD=0;
fstream outputfile;
outputfile.open("./RACH_agent100_MD5000_result.txt",ios::out | ios::trunc);
device MD[Total_MD];
agent agent[Total_agent];
srand(time(0));
for(int i=0;i<(Total_MD-count_MD);i++)//initil all MD
{
srand(time(0));
MD[i].phase=0;
MD[i].traned_time=0;
MD[i].next_trans=0;
MD[i].success_time=0;
MD[i].x=Nor(randint(2,5),randint(3,9));
MD[i].y=Nor(randint(2,5),randint(2,9));
MD[i].x= Nor(rand(),randint(1,5)%randint(3,8));
MD[i].agent=false;
srand(time(0));
MD[i].y=Nor(rand(),rand());
}
for(int i=0;i<Total_agent;i++)//initial all agent
{
srand(time(0));
agent[i].x=Nor(rand(),rand());
srand(0);
agent[i].y=Nor(rand(),rand());
agent[i].contention_time=0;
agent[i].selected=true;
agent[i].phase=0;
agent[i].traned_time=0;
agent[i].success_time=0;
}
int count=0; // 计数有透过agent的MD
for(int i=0;i<Total_agent;i++)
{
double d = (agent[i].x - MD[i].x)
* (agent[i].x - ((/*sqare this*/d = MD[i].x + agent[i].y -
MD[i].y) * d)); //2D平面distance
d=sqrt(d);
if(d==0)
{
MD[i].agent=true; //有透过agent
count++;
}
for(i=0;i<count; i++) //not agent but canditate
{
agent[i].phase=0;
agent[i].traned_time=0;
agent[i].next_trans=0;
agent[i].success_time++;
}
int countagent; //离eNB很近
for(i=0;i<Total_MD;i++)
{
for(int i=0;i<Total_agent;i++)
{
double dist = (agent[i].x - MD[i].x)//distance
* (agent[i].x - ((/*sqare this*/d = MD[i].x + agent[i].y -
MD[i].y) * d));
double d =(agent[i].x -MD[i].x)
*(agent[i].x-((/*sqare this*/d = MD[i].x + agent[i].y - MD[i].y) * d));
d= sqrt(d);
if(d==0)//坐落在eNB上
{
if(d<0)
{
agent[i].contention_time=0;
agent[i].selected=true;
countagent++;
}
}
for(int i=0;i< count_MD;i++) //MD neihbor has agent, so use RACH
{
MD[i].phase=0;
MD[i].next_trans=0;
MD[i].success_time++;
MD[i].traned_time=0;
}
cout<< countagent << endl;
}
我的错误讯息是显示在最后一行
错误讯息是这个
[Error] expected '}' at end of input
可以请大大们帮我看看吗Orz 上网google都只有英文的...
作者: Ninja5566 (苦味)   2014-09-12 12:23:00
大括号没成对之类的问题吧
作者: flydragon198 (Richard)   2014-09-12 12:32:00
在main里面少了三个 } ,{}没有成对

Links booklink

Contact Us: admin [ a t ] ucptt.com