哪位C语言高手救救我啊

2024-11-23 07:02:14
推荐回答(6个)
回答(1):

除了主要错误外,还帮你修改了一些特殊的,细节上的,不会想到的错误,自己研究下就知道了哦,呵呵
#include
struct sequenctial_list
{
char score[100];
int len;
}list;
void creat()
{
int n,i;
printf("Input n:");
scanf("%d\n",&n);
for(i=0;i scanf("%c",&list.score[i]);
list.len=n;
for(i=0;i printf("%c ",list.score[i]);
}
void insert(int h,char m)
{
int j;
if(h<0||h>list.len)
printf("Error");
else
{
for(j=list.len-1;j>=h;j--)
list.score[j+1]=list.score[j];
list.score[h]=m;list.len++;
for(j=0;j printf("%c ",list.score[j]);
}
}
void main()
{

int h;
char m;
creat();
putchar('\n');
printf("Input the a character and the position you wanna insert:\n");
scanf("\n%c,%d",&m,&h);
insert(h,m);
putchar('\n');
}

回答(2):

我很负责的告诉你,先把void creat()里的print改成printf
然后list.score[j]改成&list.score[j]

回答(3):

[wxm@test lizhi]$ gcc ceshi.c -o ceshi
/tmp/ccg61MM8.o: In function `creat':
/tmp/ccg61MM8.o(.text+0xf): undefined reference to `print'
我执行了一下,你的print出现了错误.不过该函数没有返回值是怎么确认结果的有点疑问
把第9行print改成printf
显示结果为
collect2: ld returned 1 exit status
[wxm@test lizhi]$ gcc ceshi.c -o ceshi
[wxm@test lizhi]$ ./ceshi
Input n:
4

Input the a character and the position you wanna insert:
3

回答(4):

#include
struct sequenctial_list
{
char score[100];
int len;
}list;
void creat()
{
int n,i;
printf("Input n:\n");
scanf("%d",&n);
for(i=0;iscanf("%c",&list.score[i]);
list.len=n;
for(i=0;iprintf("%c ",list.score[i]);
}
void insert(int h,char m)
{
int j;
if(h<0||h>list.len)
printf("Error");
else
{
for(j=list.len-1;j>=h;j--)
list.score[j+1]=list.score[j];
list.score[h]=m;list.len++;
for(j=0;jprintf("%c ",list.score[j]);
}
}
void main()
{

int h;
char m;
creat();
putchar('\n');
printf("Input the a character and the position you wanna insert:\n");
scanf("%c %d",&m,&h);
insert(h,m);
putchar('\n');
}

回答(5):

入楼上所说,
把printf的错误改掉以后,就没问题了啊

回答(6):

第10 行printf 输入错误

正确程序:

#include
struct sequenctial_list
{
char score[100];
int len;
}list;
void creat()
{
int n,i;
printf("Input n:\n");
scanf("%d",&n);
for(i=0;iscanf("%c",list.score[i]);
list.len=n;
for(i=0;iprintf("%c ",list.score[i]);
}
void insert(int h,char m)
{
int j;
if(h<0||h>list.len)
printf("Error");
else
{
for(j=list.len-1;j>=h;j--)
list.score[j+1]=list.score[j];
list.score[h]=m;list.len++;
for(j=0;jprintf("%c ",list.score[j]);
}
}
void main()
{

int h;
char m;
creat();
putchar('\n');
printf("Input the a character and the position you wanna insert:\n");
scanf("%c %d",&m,&h);
insert(h,m);
putchar('\n');
}