C++数据结构实现!!急求!!! 大神们进来看看吧,C语言数据结构,急求!!!!!
C++\u6570\u636e\u7ed3\u6784\u5b9e\u73b0 \uff01\uff01\u6025\u6c42\uff01\uff01#include #include #define MAX_N 350int main(){ int arr[MAX_N] = {0}, i = 0; int num; printf("\u8bf7\u6309\u987a\u5e8f\u8f93\u5165\u5165\u573a\u5b66\u751f\u5b66\u53f7\uff08\u8f93\u5165-1\u65f6\u8868\u793a\u7ed3\u675f\uff09\uff1a\n"); for(;;) { scanf("%d", &arr[i++]); if(arr[i - 1] == -1) break; } printf("\u79bb\u573a\u987a\u5e8f\u4e3a\uff1a\n"); num = i - 1; for(i = 3; i > 0; --i) { int j, f = 0; for(j = num; j >= 0; --j) { if(arr[j] != -1) { if(f == 0) { f = arr[j] / 100; } if(arr[j] / 100 == f) { printf("%d ", arr[j]); arr[j] = -1; } } } } return 0;}
\u6570\u636e\u7ed3\u6784\u554a. \u7528Status\u4e0d\u4f1a\u5199 \u8bf4\u8bf4\u601d\u8def\u554a
\u4f60\u53e6\u5916\u5b9a\u4e49\u4e2a\u53d8\u91cfX \u7136\u540e\u904d\u5386\u4e00\u6b21\u90a3\u4e2a\u8868
\u7edf\u8ba1\u6240\u6709\u6570\u636e\u548c \u9664\u4e2a\u8868\u957f \u7136\u540e\u628aX\u6dfb\u52a0\u5230\u8868\u5c3e
\u6ca1\u4e86
//vs2010编译通过
#include <iostream>
#include <vector>
#include <algorithm> //STL泛型算法头文件
using namespace std;
//谓词函数,比较seat对象中元素值的大小
bool Sortofsize(int i1, int i2)
{
return i1 < i2;
}
int main()
{
vector<int> seat;
int StudentID;
cout << "请输入各班级学生学号:(Ctrl+Z end!)" << endl;
while ( cin >> StudentID )
seat.push_back(StudentID);
//stable_sort 对给定区间所有元素进行稳定排序,
//此例中vector容器元素从小到大排列。
stable_sort(seat.begin(), seat.end(), Sortofsize);
//循环遍历输出
vector<int>::const_iterator vit = seat.begin();
while ( vit != seat.end() ) {
cout << *vit << " ";
++vit;
}
cout << endl;
system("pause");
return 0;
}
" 西方有句谚语:不要重复发明轮子!
STL几乎封装了所有的数据结构中的算法,从链表到队列,从向量到堆栈,对hash到二叉树,从搜索到排序,从增加到删除......可以说,如果你理解了STL,你会发现你已不用拘泥于算法本身,从而站在巨人的肩膀上去考虑更高级的应用。"
绛旓細InfoType info; //璇ュ姬鐨勭浉鍏充俊鎭,杩欓噷鐢ㄤ簬瀛樻斁鏉冨 n } ArcNode;//寮х殑缁撶偣缁撴瀯绫诲瀷 typedef struct Vnode { //int data; //椤剁偣淇℃伅 ArcNode *firstarc;//鎸囧悜绗竴鏉″姬 } VNode;//閭绘帴琛ㄥご缁撶偣鐨勭被鍨 typedef struct { VNode adjlist[MAXV];//閭绘帴琛 int n,e;//鍥句腑椤剁偣鏁皀鍜...
绛旓細涓銆佸崟閾捐〃鐨勫缓绔 鏈変簡鍔ㄦ佸唴瀛樺垎閰嶇殑鍩虹锛岃瀹炵幇閾捐〃灏变笉闅句簡銆傛墍璋撻摼琛紝灏辨槸鐢ㄤ竴缁勪换鎰忕殑瀛樺偍鍗曞厓瀛樺偍绾挎ц〃鍏冪礌鐨勪竴绉鏁版嵁缁撴瀯銆傞摼琛ㄥ張鍒嗕负鍗曢摼琛ㄣ佸弻鍚戦摼琛ㄥ拰寰幆閾捐〃绛夈傛垜浠厛璁茶鍗曢摼琛ㄣ傛墍璋撳崟閾捐〃锛屾槸鎸囨暟鎹帴鐐规槸鍗曞悜鎺掑垪鐨勩備竴涓崟閾捐〃缁撶偣锛屽叾缁撴瀯绫诲瀷鍒嗕负涓ら儴鍒嗭細1銆佹暟鎹煙锛氱敤鏉ュ瓨鍌...
绛旓細1銆乻tdio.h锛岃繖涓槸鐢ㄦ潵杈撳叆杈撳嚭銆傚姩鎬佸唴瀛樺垎閰嶅嚱鏁拌鐢ㄥ埌鐨勶紝鎵浠ヨ鍖呭惈malloc.h锛屽叾浠栫殑杩樺彲鑳界敤鍒板瓧绗︼紙涓诧級澶勭悊鍑芥暟锛堥渶鍖呭惈string.h澶存枃浠讹級銆佹暟瀛﹀嚱鏁帮紙闇鍖呭惈math.h锛夛紝鍖呭惈浠涔堝ご鏂囦欢涓昏鐪媔浣犳兂鐢ㄨ繖浜鏁版嵁缁撴瀯瀹炵幇浠涔堝姛鑳斤紝鐢ㄥ埌浠涔堝嚱鏁般2銆C璇█甯哥敤澶存枃浠讹細ALLOC.H 璇存槑鍐呭瓨绠$悊鍑芥暟(鍒嗛厤...
绛旓細///*鏄剧ず鏁版嵁*/// /// void show(link l){ link p; int j;p=l;j=0;cout<<"閾捐〃鐨勫间负锛歕n";while(p->next){ cout<next->date<<endl;p=p->next;} } /// /// ///閿姣侀摼琛/// /// void destorylinst(link &L){ while(L)...
绛旓細/*姝d綅搴(鎻掑湪琛ㄥ熬)杈撳叆n涓厓绱犵殑鍊硷紝寤虹珛甯﹁〃澶缁撴瀯鐨勫崟閾剧嚎鎬ц〃*/ /*鎸囨暟绯绘暟涓瀵逛竴瀵硅緭鍏*/ void CreatePolyn(PolynList &L,int n) { int i; PolynList p,q; L=(PolynList)malloc(sizeof(PolynNode)); // 鐢熸垚澶寸粨鐐 L->next=NULL; q=L; printf("鎴...
绛旓細Lobert L.Kruse 鍦ㄣ鏁版嵁缁撴瀯涓庣▼搴忚璁°嬩竴涔︿腑,灏嗕竴涓暟鎹粨鏋勭殑璁捐杩囩▼鍒嗘垚鎶借薄灞傘佹暟鎹粨鏋勫眰鍜瀹炵幇灞傘傚叾涓,鎶借薄灞傛槸鎸囨娊璞℃暟鎹被鍨嬪眰,瀹冭璁烘暟鎹殑閫昏緫缁撴瀯鍙婂叾杩愮畻,鏁版嵁缁撴瀯灞傚拰瀹炵幇灞傝璁轰竴涓暟鎹粨鏋勭殑琛ㄧず鍜屽湪璁$畻鏈哄唴鐨勫瓨鍌ㄧ粏鑺備互鍙婅繍绠楃殑瀹炵幇銆 閲嶈鎰忎箟 涓鑸涓,涓涓暟鎹粨鏋勬槸鐢辨暟鎹厓绱犱緷鎹煇绉嶉昏緫...
绛旓細缁撴灉锛1 1 4 2 6 3 include <stdio.h> include <malloc.h> struct poly //璁剧疆缁撴瀯浣 { int xi;int zhi;struct poly *next;};struct poly *jianli(void) //寤虹珛閾捐〃 { struct poly *p1,*head1,*p2;head1=(struct poly*)malloc(sizeof(poly));p1=(struct poly*)malloc(sizeof(poly...
绛旓細cout<<"鎮ㄦ煡鎵剧殑鏁版嵁涓嶅湪绾挎ц〃涓."<<endl;return l;} link * del(link *l, int i){ link *p,*s;p=get(l,i-1);if(p==NULL)cout<<"杈撳叆鏈夎"<<endl;else { s=p->next;p->next=s->next;free(s);} return l;} link * add(link *l ){ link *p,*s;cout<<"璇疯緭鍏...
绛旓細int In(char c){ int n;switch(c){ case '+':case '-':case '*':case '/':case '(':case ')':case '#':n=1;break;default:n=0;break;} return n;} char Precede(char x,char y){ int i,j;int form[7][7]={{1,1,-1,-1,-1,1,1},{1,1,-1,-1,-1,1,1},...
绛旓細void Function(char *p1,char *p2,int &l1,int &l2){ for(int i=0;i<l2;i++){ bool sign=false;for(int j=0;j<l1;j++){ if(p2[i]==p1[j]) //濡傛灉lb涓殑鏌愪釜瀛楃鍦╨a涓嚭鐜拌繃 { for(int k=j;k<l1;k++)p1[k]=p1[k+1]; //鎶妉a涓粠杩欎釜瀛楃寮濮嬶紝鍚庝竴涓綅缃鐩...