在")"之前错误预期表达式令牌和C错误 - 错误:在']'之前的预期表达式代币

时间:2014-01-30 09:19:51

标签: c data-structures deque

这是我的代码:

#include <stdio.h>
#include <conio.h>
#define MAX 10;

int rradhe[MAX];
int koka = -1;
int bishti = -1;

void shto_djathas()
{
int element;

if ((koka == 0 && bishti == MAX -1 )||koka ==  bishti +1)
{
    printf("\nGjendje Overflow");
    getch ();int rradhe[MAX];
int koka = -1;
int bishti = -1;
    return;
}
if (koka == -1)
{
    koka = 0;
    bishti = 0;
}
else
    if (koka == MAX -1)
    bishti = 0;
else
    bishti = bishti + 1;
    printf ("\n Shtypni elementin qe doni te shtoni ");
    scanf ("%d", &element);
}

void main () {
    int c;
while(1){
printf("---------------------------");
printf("\nDetyre Kursi - Ivi Hysenbelli , Olsi Lala");
printf("\n 1 - Shtoni element ne rradhe"); // elementet do te shtohen nga e djatha
printf("\n 2 - Hiq element nga e djatha(Nga fillimi)");
printf("\n 3 - Hiq element nga e majta(Nga fundi)");
printf("\n 4 - Afisho rradhen");
scanf("%d",&c);
switch (c) {

case 1:
    shto_djathas();
    break;



}

}
}

我无法理解为什么会向我显示此错误。

错误代码在行上 5。 13。 16。 27 我尝试了几乎所有的东西,并阅读了太多的论坛,但我不知道为什么。 这是我在c编程中的第一个deque,我将非常感谢你的帮助。 提前谢谢。

P.S。对不起我的英文

2 个答案:

答案 0 :(得分:3)

从宏定义中删除分号

#define MAX 10;应为#define MAX 10

了解为什么not to use semicolon in the end of macro

答案 1 :(得分:0)

这是您修改后的代码:

#include <stdio.h>
#include <conio.h>
#define MAX 10

int rradhe[MAX];
int koka = -1;
int bishti = -1;

void shto_djathas()
{
int element;

if ((koka == 0 && bishti == MAX -1 )||koka ==  bishti +1)
{
    printf("\nGjendje Overflow");
    getch ();int rradhe[MAX];
int koka = -1;
int bishti = -1;
    return;
}
if (koka == -1)
{
    koka = 0;
    bishti = 0;
}
else
    if (koka == MAX -1)
    bishti = 0;
else
    bishti = bishti + 1;
    printf ("\n Shtypni elementin qe doni te shtoni ");
    scanf ("%d", &element);
}

int main () {

    int c;
    while(true){
        printf("---------------------------");
        printf("\nDetyre Kursi - Ivi Hysenbelli , Olsi Lala");
        printf("\n 1 - Shtoni element ne rradhe"); // elementet do te shtohen nga e djatha
        printf("\n 2 - Hiq element nga e djatha(Nga fillimi)");
        printf("\n 3 - Hiq element nga e majta(Nga fundi)");
        printf("\n 4 - Afisho rradhen");
        scanf("%d",&c);

        if (c == 1)
            shto_djathas();
    }
    return 0;
}