(bai 14 tr980)dung con tro nhap day ky tu thay di ky tu 'a' thanh 'b' roi xuat Mã: //(bai 14 tr980)dung con tro nhap day ky tu thay di ky tu 'a' thanh 'b' roi xuat #include<iostream.h> #include<string> using namespace std; int main() { int i,n; char *p; p=new char[100]; cout<<"Moi nhap chuoi ky tu (phai co chu a nhe ) "; cin.getline(p,100); n=strlen(p); for(i=0;i<n;i++) {if(p[i]=='a') p[i]='b'; } cout<<"chuoi da duoc thay doi :"<<endl; cout<<p<<endl; return 0; } cho sau ky tu(dang con tro) .hay in nguoc sau ra mang hinh Mã: //cho sau ky tu(dang con tro) .hay in nguoc sau ra mang hinh #include<iostream.h> #include<string> using namespace std; int main() { char *p; int i,n; p=new char[100]; cout<<"Moi nhap chuoi :"; cin.getline(p,100); n=strlen(p); cout<<" Chuoi in nguoc la "<<endl; for(i=n-1;i>=0;i--) cout<<p[i]; cout<<endl; return 0; } (Bai 19 tr 99)dung con tro copy tu s sang t doan bat dau tu vi tri m voi do dai n Mã: //dung con tro copy tu s sang t doan bat dau tu vi tri m voi do dai n #include<iostream.h> #include<string> using namespace std; int main() { int m,n; char *s,*t; s=new char[100]; t=new char[100]; cout<<"Moi nhap sau ky tu s"; cin.getline(s,100); cout<<"moi nhap vi tri m :"<<endl; cin>>m; cout<<"moi nhap vi tri n :"<<endl; cin>>n; cout<<strncat(t,s+m,n); return 0; } (bai 21 tr99)nhap sau thong ke cac chu so '0'....'9' co trong sau. Mã: //(bai 21 tr99)nhap sau thong ke cac chu so '0'....'9' co trong sau. #include<iostream.h> #include<string> using namespace std; int main() { int i,n,a[10]; char str[100]; cout<<"Moi nhap sau :"<<endl; cin.getline(str,100); n=strlen(str); for(i=0;i<=9;i++) a[i]=0; for(i=0;i<n;i++) if(str[i]>='0'&&str[i]<='9') a[str[i]-'0']++; for(i=0;i<=9;i++) cout<<"co "<<a[i]<<"so "<<i<<endl; return 0; }