Input: A set of integers greater than or equal to 0, regardless of illegal input, separated by "," between each integer, the total length of the input character is less than or equal to 100.
Output: According to the order from large to small, if there is continuous in the middle, only output the maximum and minimum value, the input of the various whole is not the same, do not consider the same situation. Separate integers with ",".
Cases:
Input: 1,4,7,2,5,8,9,11
Output: 11,9,7,5,4,2,1
1#include <stdio.h>2#include <stdlib.h>3#include <iostream>4#include <math.h>5#include <vector>6 intMain ()7 {8 Char*input = (Char*)malloc( -*sizeof(Char));9memset (Input,0,sizeof(input));Tenscanf"%s", input); Onestd::vector<int>Input_number; A while((*input >='0') && (*input <='9') && (*input!=' /')) - { - if(*input!=',') the { - Charstr[5] =" /"; - inti =0; - while((*input! =',') && (*input!=' /')) + { -str[i++] = *input; +input++; A } at if(strlen (str) >1) - { - input_number.push_back (atoi (str)); - } - Else - { inInput_number.push_back (* (* (input-1) -'0')); - } to } +input++; - } the intCount =0; * for(std::vector<int>::iterator iter_out = Input_number.begin (); Iter_out! = Input_number.end (); iter_out++,count++) $ {Panax Notoginseng for(std::vector<int>::iterator iter_in = Input_number.begin (); Iter_in! = Input_number.end ()-1-Count; iter_in++) - { the if((*ITER_IN) < (* (iter_in+1))) + { A inttmp; thetmp=*iter_in; +*iter_in = * (iter_in +1); -* (iter_in +1) =tmp; $ } $ } - } - for(std::vector<int>::iterator iter = Input_number.begin (); ITER < Input_number.end ()-2;) the { - intFlag = ((*iter) +* (iter+2))-2* (* (iter+1));Wuyi if(!flag) the { -Iter=input_number.erase (iter+1); Wu } - Else About { $iter++; - } - } - for(std::vector<int>::iterator iter = Input_number.begin (); Iter! = Input_number.end ()-1; iter++) A { +printf"%d,", *iter); the } -std::vector<int>::iterator iter = Input_number.end ()-1; $printf"%d\n",*iter); the GetChar (); the GetChar (); the return 0; the}
String Detection One