Enter an integer, such as 12336544, or 1750, and then start the output from the last one, and finally if it is 0, then not output, the output number is not a repeating number, so the above output is 456321 and 571. If it is negative, such as input-175, output-571.
#include <iostream> #include <string>using namespace std;//Reverse char * revs (char *s) {int J = strlen (s)-1; int I=0;char T;while (i<j) {t = s[i];s[i++]=s[j];s[j--]=t;} return s;} void process (const char *PINPUTSTR, long Linputlen, char *poutputstr) {bool Flag[10] = {0}; Int j = 0;int flag_0=0; for (int i = 0;i < linputlen;i++) {if (Flag[pinputstr[i]-' 0 '] = = 0)//pinputstr[i] appears for the first time. {if (Pinputstr[i]-' 0 ' ==0 && flag_0==0); else{flag_0=1;poutputstr[j++] = Pinputstr[i]; flag[pinputstr[i]-' 0 '] = 1; }}} poutputstr[j]= ' + '; for (i=0;i<j;i++) Cout<<poutputstr[i];cout<<endl<<endl;} int main () {char *input=new char[100];char *output=new char[100];char *s=new char[100];char *ss;int k=0;while (cin> >input) {k=0;if (input[0]== '-') {cout<< "-"; for (int i=1;i<strlen (input); i++) s[k++]=input[i];s[k]= ' + '; Ss=revs (s);p rocess (Ss,strlen (ss), output);} Else{ss=revs (Input);p rocess (Ss,strlen (ss), Output);}} DeletE input;delete output;delete S;return 0;}
Huawei Machine Test-integer reverse order and go to weight