Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C++ Character Array Converted to Integer Array
C++ Character Array Converted to Integer Array
//The code was modified, and all the modified places were commented. Ask me if you don't understand.

//In fact, you can only get single digits. If it exceeds two digits, it will not work in this way.

# Contains? " string.h "

# include & ltiostream & gt

Use? Namespace? std

int? main(int? argc,? char*? argv[])

{

Cout & lt& lt "Please select the sorting method you want:"

Cout & lt& lt" 1. bubble classification "

Cout & lt& lt"2. Choose a sort "

int? Choose;

CIN & gt; & gt selection;

CIN . get();

Cout & lt& lt "Please enter a number to sort:"

const? int? max _ size = 99

Charles? str[max _ size];

cin.getline(str,max _ size);

int? array[max_size],I,count

//count = strlen(str)- 1;

Count? =? strlen(str); //Use the length of the entire character array here.

int? j? =? 0; //? How many numbers were recorded?

for(i=0,j? =? 0; I < count; i++)

{

//? Str[i] may be a space, so judge.

What if? (str[i]? ==? '?' )

{

Continue;

}

array[j]= str[I]-' 0 ';

j++;

}

Count? =? j;

for(I = 0; I < count; i++)

cout & lt& ltarray[i]? ;

System ("suspended");

Return? 0;

}