#正文之前
好久没弄C++了,上学期颓废了半学期,这学期开学就搞课程设计快疯了。待会要考试CSP,所以弄点代码储备,待会到了考场说不定能省点功夫!
正文
#include#include #define Max 1000using namespace std;struct Graph{ int a[10][10];};bool visited[10];queue path;int width=0;void BFS(Graph tu,int start){ visited[start]=true; path.push(start); while(path.size()!=0) { int top=path.front(); path.pop(); visited[top]=true; cout< < >a>>b; tu.a[a][b]=tu.a[b][a]=1; } BFS(tu,1);}复制代码
Output:
Last login: Sun Mar 18 11:46:37 on ttys000= * = * = * = * = * = * = * = * = * = * = * = * = * = * ✧。٩(ˊᗜˋ)و✧* Hello! Welcome 张照博!!开启愉快的一天吧!= * = * = * = * = * = * = * = * = * = * = * = * = * = * /Users/zhangzhaobo/program/C++/BFS ; exit;HustWolf:~ zhangzhaobo$ /Users/zhangzhaobo/program/C++/BFS ; exit;1 4 1 3 1 5 2 5 2 3 4 5 5 6 5 7 1345267logoutSaving session......copying shared history......saving history...truncating history files......completed.[进程已完成]复制代码
正文之后
祝我好运!发誓这次考试后一定苦学!上学期太飘了。