发新话题
打印

error C2143: syntax error : missing ';' before '}'

error C2143: syntax error : missing ';' before '}'

一个很简单的问题,我怎么找不到哪少了;

#include<stdio.h>
#include <iostream>
typedef struct node/*定义队列结点类型*/
        {   int t;
                int time;
                struct node * next;
        }QNode;              
typedef struct
        {
                QNode *front,*rear;
                int num;
        }LQueue;                   /*头尾指针封装*/

void main()
{
        int queue,probability,max,duration,seed,i,j,m,n;
    QNode *q,*L;
        LQueue *a[50];               /*定义指向队列指针的存放数组*/
        printf("Enter these parameters of the simulation:\nThe number of queue/server pairs: ");
        scanf("%d",&queue);
        printf("\nThe probability that a customer arrives in one tick (%):");
    scanf("%d",&probability);
    printf("\nThe maximum duration of a transaction in ticks:");
    scanf("%d",&max);
    printf("\nThe duration of the simulation in ticks:");
    scanf("%d",&duration);
        printf("\nEnter a random number seed");
        scanf("%d",&seed);
        for(i=0;i<queue;i++)/*创造队并初始化*/
        {
                a=(LQueue*)malloc(sizeof(LQueue));
                a->front=a[n]->rear=NULL;
        }
   srand(seed );  //产生随机数  
   for(i=0;i<100;i++)
           {
           j=(rand()%100);
          printf("%d",j);
   }
  

/*入队操作,*/
    for(i=1;i<=duration;i++)//时刻的循环
        {   
                //每一队的每个结点的time加一,每结点的t减一
                for(n=0;n<queue-1;n++)
                {
                        q=a[n]->front;
                        if(q!=NULL)
                        {
                                q->t--;
                            q->time++;
                                q=q->next;
                        }
                }
       
                //看是否有个进队
                j=(rand()%100);
                if(j>probability)//此时无人进队
                        continue;
                else//有人进队时
                {   L=(QNode*)malloc(sizeof(QNode));
                    L->next=NULL;
                        L->time=0;
                        m=0;
                        for(n=0;n<queue-1;n++)
                        {
                               
                                if(a[n]->num>a[n+1]->num)
                                        m=n+1;
                        }//找出哪个队的人少,一样的话先第一个队
                        if(a[m]->rear==NULL)
                        {
                                a[m]->front=L;
                            a[m]->rear=L;
                        }
                        else
                        {  
                                a[m]->rear->next=L;
                            a[m]->rear=L;
                        }
                }
                //看是否有人出队
                for(n=0;n<queue-1;n++)
                        {
                               
                                if(a[n]->front->t=0)
                                {
                                        q=a[n]->front;
                                        a[n]->front=a[n]->front->next;
                                        free(q);
                                        if(a[n]->front==NULL)
                                                a[n]->rear=NULL;
                                        else
                                                a[n]->front->t=j=(rand()%100);//后面如果有人的话就补过来,并随机分配一个工作时长
                                }//出队操作
                                else
                                        continue;
                    }
                }

        }
}
               





                /*每个队中的每个结点单元中的time数加一,最前面的那一个从开始成为首结点时t每一次减一,直到为零时释放,*/

TOP

分号我不管.自己查..
你这完全就是在c代码里添加了个<iostream>冒充cpp嘛...
hello, world......
學個語言就這句話你煩不煩......

TOP

发新话题