program bai_10_chuong_4;
uses crt;
var
s: string[100];
i, dem: integer;
Begin
clrscr;
write('Nhap xau vao:'); readln(s); dem:= 0;
for i:= 1 to length(s) do
if ('0'<=s[i]) and(s[i]<=’9') then dem:=dem+l;
Writeln('Trong xau s co '»dem,' chu so thap phan');
readln;
End.
uses crt;
var st:string[100];
i,d,kt:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
kt:=0;
for i:=1 to length(st) do
if st[i]<>st[length(st)-i+1] then kt:=1;
if kt=0 then write('Xau doi xung')
else writeln('Xau khong doi xung');
readln;
end.
code đây bạn c++ nha:
#include<bits/stdc++.h>
using namespace std;
char doixung(char s1[100])
{
long long i;
for(i=0;i<strlen(s1)/2;i++)
{
if(s1[i] != s1[strlen(s1)-1-i])
return 0;
}
return 1;
}
int main()
{
char s1[100];
cin>>s1;
if(doixung(s1)==0)
{
cout<<"k la cxau doi xung";
}
if(doixung(s1)==1)
{
cout<<"la xau doi xung";
}
return 0 ;
}