nhập 1 chuỗi bất kì và xoá các kí tự là chữ số.
vd: "124asdwa52a15" sau khi xoá => "asdwaa" .
mong các anh em giúp đỡ . cám ơn trước luôn nhé
vd: "124asdwa52a15" sau khi xoá => "asdwaa" .
mong các anh em giúp đỡ . cám ơn trước luôn nhé
#include <iostream>
#include <string>
using namespace std;
int main()
{
// get input string
string inputString;
cout << "Input-string : ";
getline(cin, inputString);
// write result
cout << "Result : ";
for(int i = 0 ; i < inputString.length() ; ++ i)
if(inputString[i] < '0' || inputString[i] > '9')
cout << inputString[i];
cout << endl;
// successfull termination
return(0);
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
// get input string
string inputString;
cout << "Input-string : ";
getline(cin, inputString);
// write result
cout << "Result : ";
for(int i = 0 ; i < inputString.length() ; ++ i)
if(inputString[i] < '0' || inputString[i] > '9')
cout << inputString[i];
cout << endl;
// successfull termination
return(0);
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
// get input string
string inputString;
cout << "Input-string : ";
getline(cin, inputString);
// write result
cout << "Result : ";
for(int i = 0 ; i < inputString.length() ; ++ i)
if(inputString[i] < '0' || inputString[i] > '9')
cout << inputString[i];
cout << endl;
// successfull termination
return(0);
}
#include <iostream> #include <string.h> using namespace std; int main() { string str; cin>>str; for(int i=0; i<str.length(); i++) if(str[i]<'A' || (str[i] < 'a' && str[i] >'Z') || str[i] >'z') {str.erase(i,1); i--;} cout<<str<<endl; system("pause"); }
string result;
int resultLength = 0;
for (int i = 0 ; i < inputString.length() ; ++ i)
if (inputString[i] < '0' || inputString[i] > '9')
result[resultLength ++] = inputString[i];
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// define constant
#define MAXLENGTH 30
int main()
{
// get input string
char *input = new char[MAXLENGTH];
printf("Input, please : ");
gets(input);
// remove digit-character
char *output = new char[MAXLENGTH];
int index = 0;
for(int i = 0 ; i < strlen(input) ; ++ i)
if(input[i] < '0' || input[i] > '9')
output[index ++] = input[i];
// result
printf("Result : %s\n", output);
delete [] output;
delete [] input;
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// define constant
#define MAXLENGTH 30
int main()
{
// get input string
char *input = new char[MAXLENGTH];
printf("Input, please : ");
gets(input);
// remove digit-character
char *output = new char[MAXLENGTH];
int index = 0;
for(int i = 0 ; i < strlen(input) ; ++ i)
if(input[i] < '0' || input[i] > '9')
output[index ++] = input[i];
// result
printf("Result : %s\n", output);
delete [] output;
delete [] input;
return 0;
}
Comment