Ali 2015 Internship A problem

Source: Internet
Author: User

#include <iostream> #include <vector>using namespace std, #define INF 1000int Zhao_zuixiaozhi (vector<int > &ary); int Cout_xulie (vector<int> &ary) {int Jishu_number=0;int now_min_numver;int now_min;vector <int>ary_temp=ary;now_min_numver=zhao_zuixiaozhi (ary_temp); Now_min=ary_temp[now_min_numver];ary_temp[now _min_numver]=inf;cout<<now_min;jishu_number++;int next_min_number;int next_min;int ary_size=ary_temp.size () ; while (jishu_number<ary_size) {Next_min_number=zhao_zuixiaozhi (ary_temp); Next_min=ary_temp[next_min_number]; if (next_min_number<now_min_numver) {cout<< ', ' <<next_min;jishu_number++;} Else{cout<<endl;cout<<next_min;jishu_number++;now_min=next_min;now_min_numver=next_min_number;} Ary_temp[next_min_number]=inf;} return 1;} int Zhao_zuixiaozhi (vector<int> &ary) {vector<int>::iterator i_beging,i_end;int min_result,min_ Number,i=0;min_result=ary[0];min_number=0;for (i=0;i!= (Ary.size ()); i++) {if (Ary[i]<min_result) {min_result=ary[i];min_number=i;}} return min_number;} int main () {vector<int> ary;ary.push_back (1); Ary.push_back (2); Ary.push_back (5); Ary.push_back (8); ary.push_    Ary.push_back (4); Ary.push_back (3); Ary.push_back (6);    Ary.push_back (9); Ary.push_back (7); Cout_xulie (ary);//cout<<zhao_zuixiaozhi (ary) <<endl;//int a[10]={1,2,3};//ary={1,2,8,10,4,3,6,9,7};/ /cout_xulie (ary); System ("pause"); return 1;}

  

Ali 2015 Internship A problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.