Nhập một ký tự a, viết chương trình thực hiện các công việc sau:- Nếu a=’S’ thì thực hiện phép tính 20+30;- Nếu a=’P’ thì thực hiện phép tính 20*30
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.
Program HOC24;
var s: string;
tg,d,max,i: byte;
code: integer;
begin
write('Nhap xau : '); readln(s);
// cau a
for i:=1 to length(s) do if s[i] in ['a'..'z'] then write(upcase(s[i]));
//------
writeln;
//-cau b
for i:=length(s) downto 1 do if s[i] in ['0'..'9'] then write(s[i]);
//------
writeln;
//---cau c
d:=0;
for i:= 1 to length(s) do
if s[i] in ['0'..'9'] then
begin
val(s[i],tg,code);
if tg>max then max:=tg;
d:=d+1;
end;
if d=0 then write('Khong co chu so trong day') else write('Chu so lon nhat la : ',max);
readln
end.
uses crt;
var st,st1:string;
d,i,d1,max,x,y:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Day cac ki tu thuong doi sang chu hoa la: ');
for i:=1 to d do
if st[i] in ['a'..'z'] then write(upcase(st[i]):4);
st1:='';
for i:=1 to d do
if st[i] in ['0'..'9'] then st1:=st1+st[i];
d1:=length(st1);
for i:=d1 downto 1 do
write(st1[i]:4);
writeln;
max:=0;
for i:=1 to d1 do
begin
val(st1[i],x,y);
if max<x then max:=x;
end;
writeln('Chu so lon nhat trong xau la: ',max);
readln;
end.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Xau vua nhap la: ',st);
for i:=1 to d do
if st[i] in ['a'..'z'] then upcase(st[i]);
writeln(st);
readln;
end.
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Xau vua nhap la: ',st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln('Xau moi la: ',st);
readln;
end.
2:
uses crt;
var a:array[1..100]of integer;
i,n,dem,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
b[1]:=a[1];
dem:=1;
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if b[j]=a[i] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
uses crt;
var thu:integer;
begin
clrscr;
repeat
write('Nhap thu:'); readln(thu);
until (2<=thu) and (thu<=8);
case thu of
2: writeln('Monday');
3: writeln('Tuesday');
4: writeln('Wednesday');
5: writeln('Thursday');
6: writeln('Friday');
7: writeln('Saturday');
8: writeln('Sunday');
end;
readln;
end.
uses crt;
var a,b,c,p,s,am,bn,cp:real;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then
begin
writeln('Day la ba canh trong mot tam giac vuong');
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Dien tich tam giac la: ',s:4:2);
am:=sqrt(2*(sqr(b)+sqr(c))-sqr(a))/4;
bn:=sqrt(2*(sqr(a)+sqr(c))-sqr(b))/4;
cp:=sqrt(2*(sqr(a)+sqr(b))-sqr(c))/4;
writeln('Do dai duong trung tuyen ung voi canh a la: ',am:4:2);
writeln('Do dai duong trung tuyen ung voi canh b la: ',bn:4:2);
writeln('Do dai duong trung tuyen ung voi canh c la: ',cp:4:2);
end
else writeln('Day khong la ba canh trong mot tam giac');
readln;
end.
Var a:array:[1..1000] of integer;
i,n,max,t,d:integer;
s:longint;
tb:real;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
tb:=s/n;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
writeln('Trung binh cong cua day la ',tb:10:2);
Write('Cac so la boi cua 3 la ');
For i:=1 to n do
if a[i] mod 3 = 0 then write(a[i]:8);
writeln;
write('Cac so le la boi cua 5 la ');
for i:=1 to n do
if (a[i] mod 2 <> 0) and (a[i] mod 5 = 0) then
write(a[i]:8);
Writeln;
max:=a[1];
for i:=1 to n do
if a[i] > max then
begin
max:=a[i];
d:=i;
End;
Writeln('So lon nhat la ',max);
t:=a[1];
a[1]:=max;
a[d]:=t;
Write('Day sau khi dem so lon nhat ra truoc ');
For i:=1 to n do
write(a[i]:8)
writeln;
tb:=(a[8] + a[10])/2);
Write(Trung binh cong cua so thu 8 va thu 10 la ',tb:10:2);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
char a;
int main()
{
cin>>a;
if (a=='S') cout<<"50";
else cout<<"600";
return 0;
}