K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

16 tháng 10 2023

#include <bits/stdc++.h>

using namespace std;

string S;

int t=0;

int main(){

cin >> S;

for (int i=0;i<S.size();i++)

if (S[i]>='0'&&S[i]<='9')

t=t+int(S[i]-48);

cout <<t;

return 0;

}

uses crt;

var x,n,d,i:longint;

st,st1:string;

a:integer;

{----------------------chuong-trinh-con-tim-ucln---------------------}

function ucln(a,b:longint):longint;

var t:longint;

begin

   t:=b mod a;

   while t<>0 do

     begin

        t:=a mod b;

        a:=b;

        b:=t;

     end;

  ucln := a;

end;

{-------------------chuong-trinh-chinh-----------------}

begin

clrscr;

write('nhap x='); readln(x);

str(x,st);

d:=length(st);

st1:='';

for i:=d downto 1 do

  st1:=st1+st[i];

val(st1,n,a);

if ucln(x,n)=1 then writeln('Phai')

else writeln('khong phai');

readln;

end.

#include <bits/stdc++.h>
using namespace std;
long long n;
//chuongtrinhcon
int tongchuso(long long n)
{
    int t=0;
    while (n>0)
    {
        int x=n%10;
        t=t+x;
        n=n/10;
    }
    return(t);
}
//chuongtrinhchinh
int main()
{
   freopen("sonut.inp","r",stdin);
   freopen("sonut.out","w",stdout);
   cin>>n;
   int t=tongchuso(n);
   while (t>10)
   {
       t=tongchuso(t);
   }
   cout<<t;
   return 0;
}

 

 

uses crt;

var st:string;

i,d:integer;

begin

clrscr;

readln(st);

d:=length(st);

for i:=1 to d do

  if (st[i] in ['a'..'z']) or (st[i] in ['A'..'Z']) then write(st[i]);

writeln;

for i:=1 to d do 

if (st[i] in ['0'..'9']) then write(st[i]);

readln;

end.

20 tháng 8 2023

Làm bằng pascal nha