贴吧用户_54JNWaa
月华白莲
关注数: 5
粉丝数: 4
发帖数: 86
关注贴吧数: 20
现在送的两盒子都能开出神司马了吗 现在送的两盒子都能开出神司马了吗
各位大佬们,这出现的问题怎么解决,求指教#include<s 各位大佬们,这出现的问题怎么解决,求指教 #include<string.h> #include<malloc.h> #include<stdio.h> #include<math.h> #include<process.h> #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 typedef int Status; typedef int Boolean; #define MAX_NAME 3 typedef char VertexType[MAX_NAME]; #define MAX_NUM 20 typedet struct ArcNode {int adjvex; struct ArcNode * nextarc; }; typedef struct {VertexType data; struct ArcNode *firstarc; }VNode,AbjList[MAX_NUM]; typedet struct ALGraph {AdjList vertices; int vexnum,arcnum; }; typedef int DataType; typedef struct QNode {DataType data; struct QNode *next; }QNode; typedef struct {QNode *front; QNode *rear; }LinkQueue; Boolean visited[MAX_NUM]; int CreateGraph(ALGraph &G) {int i,j,k; VertexType va,vb; ArcNode *p; printf("请输入图的顶点数,边数:"); scanf("%d,%d,&G.vexnum,&G.arcnum); printf("请输入%d个顶点的值(<%d个字符):\n",G.vexnum,MAX_NUM); for(i=0;i<G.vexnum;++i) { scanf("%s",G.vertices[i].data); G.vertices[i].fridtarc=NULL; } printf("请顺序输入每条弧(边)的弧尾和弧头(以空格作为间隔):\n"); for(k=0;k<g.arcnum;++k) {scanf("%s%s",va,vb); i=LocateVex(g,va); j=LocateVex(g,vb); p=(ArcNode *)malloc(sizeof(ArcNode)); p->adjvex=j; p->nextarc=G.vertices[i].firstarc; G.vertices[i].firstarc=p; } return 1; } void DFS(ALGraph &G,int v) {int w; VertexType v1,w2; strcpy(v1,GetVex(G,v)); visited[v]=TRUE; printf("%s",G.vertices[v].data); for(w=FirstAdjVex(G,v1);w>=0;w=NextAdjVex(G,v1,strcpy(w1,GetVex(G,w)))) if(!visited[w]) DFS(G,w); } void DFSTraverse(ALGraph &G) {int v; for(v=0;v<G.vexnum;v++) visited[v]=FALSE; for(v=0;v<G.vexnum;v++) if(!visited[v]) DFS(G,v); printf(%\n); } void BFSTtraverse(ALGraph &G) {int v,u,w; VertexType u1,w1; LinkQueue Q; for(v=0;v<G.vexnum;++v) visited[v]=FALSE; InitQueue(Q); for(v=0;v<G.vexnum;v++) if(!visited[v]) {visited[v]=TRUE; printf("%s",G.vertices[v].data); EnQueue(g,v); while(!queueempty(q)) {DeleteQueue(Q,u); strcpy(u1,GetVex(G,u)); for(w=FirstAdjVex(G,u1);w>=0;w=NextAdjVex(G,u1,strcpy(w1,GetVex(G,w)))) if(!visited[w]) {visited[w]=TRUE; printf("%s",G.vertices.data); EnQueue(Q,w); } } } printf("\n"); } int LocateVex(ALGraph G,VertexType u) {int i; for(i=0;i<G.vexnum;++i) if(strcmp(u,G.vertices[i].data)==0) return i; return -1; } VertexType& getvex(ALGraph G,int v) {if(v>=G.vexnum||v<0) exit(ERROR); return G.vertices[v].data); } int FirstAdjVex(ALGraph G,VertexType v) {ArcNode *p; int v1; v1=LocateVex(g,v); p=G.vertices[v1].firstarc; if(p) return p->adjvex; else return -1; } int NextAdjVex(ALGraph G,VertexType v,VertexType w) {ArcNode *p; int v1,w1; v1=LocateVex(G,v); w1=LocateVex(G,w); p=G.vertices[v1].firstarc; while(p&&p->adjvex!=w1) p=p->nextarc; if(!p||p->nextarc) return -1; else return p->nextarc->adjvex; } Status intiqueue(LinkQueue &Q) {if(Q.front=Q.rear=(QNode *)malloc(sizeof(QNode)))) exit(OVERFLOW); Q.front->next=NULL; return OK; } Status QueueEmpty(LinkQueue Q) {if(Q.front==Q.rear) return TRUE; else return FALSE; } Status EnQueue(LinkQueue &Q,DataType e) {QNode *p; if(!(p=(QNode *)malloc(sizeof(QNode)))) exit(OVERFLOW); p->data=e; p->next=NULL; Q.rear->next=p; Q.rear=p; return OK; } Status DeQueue(LinkQueue &Q,DataType &e) {QNode *p; if(Q.fornt=Q.rear) return ERROR; p=Q.front->next; e=p->data; Q.front->next=p->next; if(Q.rear==p) Q.rear=Q.front; free(p); return OK } void Display(ALGraph g) {int i; ArcNode *p; printf("有向图\\n"); printf("%d个顶点:\n",G.vexnum); for(i=0;i<G.vexnum;++i) printf("%s",G.vertices[i].data); printf("\n%d条弧(边):\n",G.arcnum); for(i=0;i<G.vexnum;++i) {p=G.vertices[i].firstarc; while(p) {printf("%s→%s",G.vertices[i].data,G.vertices[p->adjvex].data); p=p->nextarc; } printf("\n"); } } void main() {ALGraph g; printf("请选择有向图\n"); CreateGraph(g); Display(g); printf("采用深度优先搜索的结果:\n"); DFSTraverse(g); printf("采用广度优先搜索的结果:\n"); BFSTraverse(g); }
求各位大佬解答解答,这为什么会出问题#include<str 求各位大佬解答解答,这为什么会出问题 #include<string.h> #include<malloc.h> #include<stdio.h> #include<math.h> #include<process.h> #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 typedef int Status; typedef int Boolean; #define MAX_NAME 3 typedef char VertexType[MAX_NAME]; #define MAX_NUM 20 typedet struct ArcNode {int adjvex; struct ArcNode * nextarc; }; typedef struct {VertexType data; struct ArcNode *firstarc; }VNode,AbjList[MAX_NUM]; typedet struct ALGraph {AdjList vertices; int vexnum,arcnum; }; typedef int DataType; typedef struct QNode {DataType data; struct QNode *next; }QNode; typedef struct {QNode *front; QNode *rear; }LinkQueue; Boolean visited[MAX_NUM]; int CreateGraph(ALGraph &G) {int i,j,k; VertexType va,vb; ArcNode *p; printf("请输入图的顶点数,边数:"); scanf("%d,%d,&G.vexnum,&G.arcnum); printf("请输入%d个顶点的值(<%d个字符):\n",G.vexnum,MAX_NUM); for(i=0;i<G.vexnum;++i) { scanf("%s",G.vertices[i].data); G.vertices[i].fridtarc=NULL; } printf("请顺序输入每条弧(边)的弧尾和弧头(以空格作为间隔):\n"); for(k=0;k<g.arcnum;++k) {scanf("%s%s",va,vb); i=LocateVex(g,va); j=LocateVex(g,vb); p=(ArcNode *)malloc(sizeof(ArcNode)); p->adjvex=j; p->nextarc=G.vertices[i].firstarc; G.vertices[i].firstarc=p; } return 1; } void DFS(ALGraph &G,int v) {int w; VertexType v1,w2; strcpy(v1,GetVex(G,v)); visited[v]=TRUE; printf("%s",G.vertices[v].data); for(w=FirstAdjVex(G,v1);w>=0;w=NextAdjVex(G,v1,strcpy(w1,GetVex(G,w)))) if(!visited[w]) DFS(G,w); } void DFSTraverse(ALGraph &G) {int v; for(v=0;v<G.vexnum;v++) visited[v]=FALSE; for(v=0;v<G.vexnum;v++) if(!visited[v]) DFS(G,v); printf(%\n); } void BFSTtraverse(ALGraph &G) {int v,u,w; VertexType u1,w1; LinkQueue Q; for(v=0;v<G.vexnum;++v) visited[v]=FALSE; InitQueue(Q); for(v=0;v<G.vexnum;v++) if(!visited[v]) {visited[v]=TRUE; printf("%s",G.vertices[v].data); EnQueue(g,v); while(!queueempty(q)) {DeleteQueue(Q,u); strcpy(u1,GetVex(G,u)); for(w=FirstAdjVex(G,u1);w>=0;w=NextAdjVex(G,u1,strcpy(w1,GetVex(G,w)))) if(!visited[w]) {visited[w]=TRUE; printf("%s",G.vertices.data); EnQueue(Q,w); } } } printf("\n"); } int LocateVex(ALGraph G,VertexType u) {int i; for(i=0;i<G.vexnum;++i) if(strcmp(u,G.vertices[i].data)==0) return i; return -1; } VertexType& getvex(ALGraph G,int v) {if(v>=G.vexnum||v<0) exit(ERROR); return G.vertices[v].data); } int FirstAdjVex(ALGraph G,VertexType v) {ArcNode *p; int v1; v1=LocateVex(g,v); p=G.vertices[v1].firstarc; if(p) return p->adjvex; else return -1; } int NextAdjVex(ALGraph G,VertexType v,VertexType w) {ArcNode *p; int v1,w1; v1=LocateVex(G,v); w1=LocateVex(G,w); p=G.vertices[v1].firstarc; while(p&&p->adjvex!=w1) p=p->nextarc; if(!p||p->nextarc) return -1; else return p->nextarc->adjvex; } Status intiqueue(LinkQueue &Q) {if(Q.front=Q.rear=(QNode *)malloc(sizeof(QNode)))) exit(OVERFLOW); Q.front->next=NULL; return OK; } Status QueueEmpty(LinkQueue Q) {if(Q.front==Q.rear) return TRUE; else return FALSE; } Status EnQueue(LinkQueue &Q,DataType e) {QNode *p; if(!(p=(QNode *)malloc(sizeof(QNode)))) exit(OVERFLOW); p->data=e; p->next=NULL; Q.rear->next=p; Q.rear=p; return OK; } Status DeQueue(LinkQueue &Q,DataType &e) {QNode *p; if(Q.fornt=Q.rear) return ERROR; p=Q.front->next; e=p->data; Q.front->next=p->next; if(Q.rear==p) Q.rear=Q.front; free(p); return OK } void Display(ALGraph g) {int i; ArcNode *p; printf("有向图\\n"); printf("%d个顶点:\n",G.vexnum); for(i=0;i<G.vexnum;++i) printf("%s",G.vertices[i].data); printf("\n%d条弧(边):\n",G.arcnum); for(i=0;i<G.vexnum;++i) {p=G.vertices[i].firstarc; while(p) {printf("%s→%s",G.vertices[i].data,G.vertices[p->adjvex].data); p=p->nextarc; } printf("\n"); } } void main() {ALGraph g; printf("请选择有向图\n"); CreateGraph(g); Display(g); printf("采用深度优先搜索的结果:\n"); DFSTraverse(g); printf("采用广度优先搜索的结果:\n"); BFSTraverse(G); }
小对任务,挂树的那种,在线等id:月华之殇 小对任务,挂树的那种,在线等 id:月华之殇
哪位大佬带带我这个菜鸡双排任务呀 哪位大佬带带我这个菜鸡双排任务呀
大佬们,下面这个程序为什么答案是a呀,switch语句不是x 大佬们,下面这个程序为什么答案是a呀,switch语句不是x=1,执行a++,结果是C吗? #include<stdio.h> main() {int x=1, a=0, b=0; switch(x) {case 0:b++; case 1:a++; case 2:a++;b++;} printf(" a=%d, b=%d\n",a,b) ;} A. a=2,b=1 B. a=1, b=1 C.a=1,b=0
各位好心人#include<stdio.h>main(){i 各位好心人 #include<stdio.h> main() {int x=1, a=0, b=0; switch(x) {case 0:b++; case 1:a++; case 2:a++;b++;} printf(" a=%d, b=%d\n",a,b) ;} A. a=2,b=1 B. a=1, b=1 C.a=1,b=0 为什么答案是A能,switch语句当是x=1,执行a++吗,那应该是a=1,b=0呀
因为目前没有工具,所以想知道图片上的对不对,望大佬们帮帮忙。
大佬们,我想问问要是用Tc入门怎么样? 大佬们,我想问问要是用Tc入门怎么样?
1
下一页