标签:std 打印路径 amp mes 实现 operator while opera struct
1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a);i < (b);i ++) 3 #define pb push_back 4 5 using namespace std; 6 7 struct Node 8 { 9 int data; 10 int from,to; 11 Node *next; 12 }; 13 14 ostream& operator << (ostream& os,Node* p) 15 { 16 if(p == NULL) return os; 17 os << p->next << p->from << " " << p->to << " " << p->data << endl; 18 return os; 19 } 20 21 void add(Node* &p,int u ,int v,int da) 22 { 23 while(p && p->next!=NULL) 24 p = p->next; 25 Node *q = new(Node); 26 q->next = NULL,q -> from = u,q -> to = v,q -> data = da; 27 if(p) p -> next = q; 28 else p = q; 29 } 30 31 int main() 32 { 33 Node *path = NULL; 34 add(path,1,2,39); 35 add(path,2,3,39); 36 cout << path; 37 return 0; 38 }
真的神秘,这个重载运算符真滴????
标签:std 打印路径 amp mes 实现 operator while opera struct
原文地址:https://www.cnblogs.com/Asurudo/p/10127879.html