安卓手机c语言编程软件问题求教

求教:C语言问题_百度知道
求教:C语言问题
#include&stdio.h&#include&malloc.h&#include&stdlib.h&structnode{structnode*};structvex{structnode*};intlocatevex(structvex*w,intvvnum){in...
#include&stdio.h&#include&malloc.h&#include&stdlib.h&struct node{ struct node*};struct vex{ struct node*};int locatevex(struct vex*w,int vvnum){ for(i=0;i&i++)
if(w[i].data==v)
return -1;}struct vex* create(structvex*s,int vnum,int anum){int i,j.k; struct node*p;char ss[3];
for(i=0;i&i++)
{s[i].data=getchar();
s[i].firstarc=NULL;
} for(k=0;k&k++){gets(ss); i=locatevex(s,ss[0],vnum); j=locatevex(s,ss[1],vnum); if(i&0||j&0) {printf(&error arc&)
else {p=(struct node)malloc(sizeof(struct node));
p-&adjvex=j;
p-&next=s[i].
s[i].firstarc=p; }}//end of k}void bfs(struct vex*s,int vnum,int v ){int visited[20],q[20],front=0,rear=0,w; struct node *p; for(w=0;w&w++) visited[w]=0; printf(&%c&,s[v].data); q[rear++]=v; while(front!=rear) {w=q[front++];
while(front!=rear) {v=p-&
if(!visited[v]) {printf(&%c&,s[v].data);
visited[v]=1;
q[redr++]=v;
}//end of if}//}main(){struct vex a[20],*p; int vexnum, scanf(&vex=%d,arc=%d&,&vexnum,&arcnum) p=creat(a,nexnum,arcnum); bfs(a,vexnum,2);}急!急!急!请高手帮忙看一下,给改正过来,不胜感激!
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
tanyuguo知道合伙人
采纳数:4156
获赞数:27902
1、locatevex的声明少写了第2个参数2、create的声明中,参数的类型structvex连写了。紧接着函数体中第一句k前面的逗号写成了点3、create函数体中,printf(&error arc&)忘加分号了4、create函数体中,p=(struct node *)malloc(sizeof(struct node));注意强制转换是struct node *5、bfs函数体第3行,num改成vnum6、bfs函数体第9行,p=s[w],改成p=s[w].7、bfs函数体倒数第3行,rear写成了redr8、bfs函数体最后少写了个}9、main函数中调用create时,把create写成了creat,把vexnum写成了nexnum。而且上一句的scanf末尾没写分号#include&stdio.h&#include&malloc.h&#include&stdlib.h&struct node{ struct node*};struct vex{ struct node*};int locatevex(struct vex*w,char v,int vvnum){ for(i=0;i&i++)
if(w[i].data==v)
return -1;}struct vex* create(struct vex*s,int vnum,int anum){int i,j,k; struct node*p;char ss[3];
for(i=0;i&i++)
{s[i].data=getchar();
s[i].firstarc=NULL;
} for(k=0;k&k++){gets(ss); i=locatevex(s,ss[0],vnum); j=locatevex(s,ss[1],vnum); if(i&0||j&0) {printf(&error arc&);
else {p=(struct node *)malloc(sizeof(struct node));
p-&adjvex=j;
p-&next=s[i].
s[i].firstarc=p; }}//end of k}void bfs(struct vex*s,int vnum,int v ){int visited[20],q[20],front=0,rear=0,w; struct node *p; for(w=0;w&w++) visited[w]=0; printf(&%c&,s[v].data); q[rear++]=v; while(front!=rear) {w=q[front++];
while(front!=rear) {v=p-&
if(!visited[v]) {printf(&%c&,s[v].data);
visited[v]=1;
q[rear++]=v;
}//end of if}//}}main(){struct vex a[20],*p; int vexnum, scanf(&vex=%d,arc=%d&,&vexnum,&arcnum); p=create(a,vexnum,arcnum); bfs(a,vexnum,2);}
非常感谢!
HiLittleGirl知道合伙人
HiLittleGirl
采纳数:99
获赞数:165
很多的是最基本的错误:1.少分号2.逗号写成了点3.点写成了逗号4.int locatevex(struct vex*w,int vvnum)应该是int locatevex(struct vex*w,char v,int vvnum)不具体举出来了帮你把错误改了,还没看你程序想要实现什么#include&stdio.h&#include&malloc.h&#include&stdlib.h&struct node{ struct node*};struct vex{ struct node*};int locatevex(struct vex*w,char v,int vvnum){
for(i=0;i&i++) {
if(w[i].data==v)
return -1;}struct vex* create(struct vex*s,int vnum,int anum){ int i,j,k; struct node*p;char ss[3]; for(i=0;i&i++) {
s[i].data=getchar();
s[i].firstarc=NULL; } for(k=0;k&k++) {
i=locatevex(s,ss[0],vnum);
j=locatevex(s,ss[1],vnum);
if(i&0||j&0)
printf(&error arc&);
p=(struct node*)malloc(sizeof(struct node));
p-&adjvex=j;
p-&next=s[i].
s[i].firstarc=p;
} }//end of k}void bfs(struct vex*s,int vnum,int v ){ int visited[20],q[20],front=0,rear=0,w; struct node *p; for(w=0;w&w++) visited[w]=0; printf(&%c&,s[v].data); q[rear++]=v; while(front!=rear) {
w=q[front++];
while(front!=rear)
if(!visited[v])
printf(&%c&,s[v].data);
visited[v]=1;
q[rear++]=v;
}//end of if
}// }}int main(){ struct vex a[20],*p; int vexnum, scanf(&vex=%d,arc=%d&,&vexnum,&arcnum); p=create(a,vexnum,arcnum); bfs(a,vexnum,2); return 0;}
汗,这是作业题……不管怎样,还是谢谢你!非常感谢!
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。C语言函数问题,新人求指教,请问怎么修改?_百度知道
C语言函数问题,新人求指教,请问怎么修改?
#pragmavector=PORT2_VECTOR__interruptvoidPort_2(void){__bis_SR_register(LPM4_EXIT);g_test_mode^=0x01;//ToggleTRIGinterruptflagP2IFG&=~0x20;//ClearP2.5interruptflagif(g_te...
#pragma vector=PORT2_VECTOR__interrupt void Port_2(void){
__bis_SR_register(LPM4_EXIT);
g_test_mode ^= 0x01;
// Toggle TRIG interrupt flag
P2IFG &= ~0x20;
// Clear P2.5 interrupt flag
if(g_test_mode==1)
//P1REN = 0x06;
P1OUT |= 0x08;
if(g_gain == 3)
// If set to highest gain
g_gain = 0;
// Reset to lowest gain
g_gain = g_gain + 1;
// Increment gain
//P1REN = 0x00;
//P1OUT &= 0x06;
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
热心网友知道合伙人
#include &derivative.h& void main(void) {
while(!(CRGFLG&0x08));
CLKSEL=0xc0;
PWME_PWME1=0x00;
PWMPRCLK=0x33;
PWMSCLA=150;
PWMSCLB=150;
PWMCLK_PCLK1=1;
PWMPOL_PPOL1=1;
PWMCAE_CAE1=0;
PWMCTL_CON01=0x00;
PWMPER01=200;
PWMDTY01=20;
PWME_PWME1=1;}
莫名其妙,修改函数,重写其它有毛用!
为你推荐:
其他类似问题
您可能关注的内容
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。PHP has encountered an Access Violation at 029644DF简单C语言问题,求教?_百度知道
简单C语言问题,求教?
有时候看到形如voidproc(constinta);的函数声明那个const在这里起什么作用,求指教?...
有时候看到 形如 void proc(const int a);的函数声明那个const 在这里起什么作用,求指教?
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
xoaxa知道合伙人
采纳数:3336
获赞数:5080
这个const是告诉函数调用者,本函数不会修改实参的值(实际上也修改不了)。但当形参是数组,或指针时,const 的作用就体现出来了,如形如 void proc(const int a[], int n);,如果试图修改数组元素的值,编译器就会给出错误信息,假如函数体内有语句 a[i] = 6;,这试图越过 const 的限制,编译器会给出信息的。
jiyuan1215a知道合伙人
jiyuan1215a
采纳数:855
获赞数:1556
const就是常量的意思意思就是参数int a是一个常量,proc函数里面不会更改a的值。如果proc函数里面有再次给a赋值的语句(比如a=1),编译不通过。
本回答被网友采纳
知道合伙人
采纳数:54
获赞数:1278
传入const变量,函数栈中不用创建拷贝。a 在函数内部也无法被更改。
为你推荐:
其他类似问题
您可能关注的内容
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。C语言问题求教~? - 知乎有问题,上知乎。知乎作为中文互联网最大的知识分享平台,以「知识连接一切」为愿景,致力于构建一个人人都可以便捷接入的知识分享网络,让人们便捷地与世界分享知识、经验和见解,发现更大的世界。8被浏览383分享邀请回答赞同 添加评论分享收藏感谢收起}

我要回帖

更多关于 c语言百钱买百鸡问题 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信