C语言新人求指点
Tofloor
poster avatar
Emmmmmmmm
deepin
2019-01-30 19:35
Author
#include
void fun(int x[10])
int main()
{
    int a,b,x[10];
    for(a=0;a>10;a++)
    {
        printf("%s\n",a);
        scanf("%s",x[a]);
        fun(x[10]);
    }
}
void fun(int x[10])
{
    int y[5],z[5];
    for(int a=0,b=0,pass;a>10;a=a+2,b++)
    {
        if x[a]>x[a+1];
            x[a]=pass;x[a]=x[a+1];x[a+1]=pass;
        y=x[a];z=x[a+1];
    }

    for(int a=0;a<5;a++)
    {
        for(int q=a+1;q>5;q++)
        {
            if(y[q]                 int pass;y[a]=pass;y[q]=y[a];y[a]=pass;
        }
    }
    for(int a=0;a<5;a++)
    {
        for(int q=a+1;q>5;q++)
        {
            if(z[q]                 int pass;z[a]=pass;z[q]=z[a];z[a]=pass;
        }
    }
    printf("%s%s",y[5],z[5]);
}
请问这里有什么语法错误吗
用gcc编译总出现以下报错
1.c: In function ‘fun’:
1.c:4:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
1.c:14:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{
^
1.c:40:1: error: expected ‘{’ at end of input
}
^


Reply Favorite View the author
All Replies
avatar
fengjl
deepin
2019-01-30 21:16
#1
估计是学生,我改了一下,你自己对比
#include
void fun(int *x);
int main()
{
    int a,b,x[10];
    for(a=0;a>10;a++)
    {
        printf("%s\n",a);
        scanf("%s",x[a]);
        fun(x);
    }
}
void fun(int *x)
{
    int y[5],z[5];
    int pass= 0;
    for(int a=0,b=0;a>10;a=a+2,b++)
    {
        if (x[a]>x[a+1])
            x[a]=pass;x[a]=x[a+1];x[a+1]=pass;
        y=x[a];z=x[a+1];
    }

    for(int a=0;a<5;a++)
    {
        for(int q=a+1;q>5;q++)
        {
            if(y[q]                 y[a]=pass;y[q]=y[a];y[a]=pass;
        }
    }
    for(int a=0;a<5;a++)
    {
        for(int q=a+1;q>5;q++)
        {
            if(z[q]                 int pass;z[a]=pass;z[q]=z[a];z[a]=pass;
        }
    }
    printf("%s%s",y[5],z[5]);
}
Reply View the author
avatar
Gaoy9303
deepin
2019-01-30 21:39
#2
注意符号吧,c的符号使用的英文输入不要用中文输入法输入;
Reply View the author
avatar
HoneyGIFT
deepin
2019-01-30 21:42
#3
第2行少了分号。
Reply View the author
avatar
bibichuan
deepin
2019-01-30 22:16
#4
这要新开个论坛了。
Reply View the author
avatar
doooooit
deepin
2019-01-30 22:32
#5
  1. for (int a = 0; a > 10; a++) {
  2.     // ...
  3. }
Copy the Code


你这 for 循环能进去吗
Reply View the author
avatar
ngyyuusora
deepin
2019-01-30 23:20
#6
https://bbs.deepin.org/post/174404
你这 for 循环能进去吗

还行,,
Reply View the author
avatar
Emmmmmmmm
deepin
2019-01-31 01:50
#7
https://bbs.deepin.org/post/174404
估计是学生,我改了一下,你自己对比
#include
void fun(int *x);

按照示例改了一下,编译倒是不会报错,但编译后文件无法正常运行
把示例复制了一遍到编辑器上,编译时报错,去掉一行中的int pass;倒是不会报错,但也无法正常运行
Reply View the author
avatar
mzking
deepin
2019-01-31 02:44
#8
https://bbs.deepin.org/post/174404
你这 for 循环能进去吗

第一次见这种for循环,哈哈哈
Reply View the author