cho tệp SONGUYEN.INP chứa 3 số nguyên a,b,c có kiểu dữ liệu kiểu long long. tìm giá trị lớn nhất của 3 số trên và ghi kết quả vào tệp lonnhat.out
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.
uses crt;
var a:array[1..100]of integer;
i,n,t,j,tam:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:5);
writeln;
writeln('Cac so duong la: ');
for i:=1 to n do if (a[i]>0) then write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln(t);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do write(a[i]:4);
readln;
end.
uses crt;
var a,b,c,p,s:real;
begin
clrscr;
readln(a,b,c);
if (a>0) and (b>0) and (c>0) and (a+b>c) and (a+c>b) and (b+c>a) then
begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('Chu vi la: ',2*p:4:2);
writeln('Dien tich la: ',s:4:2);
end
else writeln('A B C khong phai la chieu dai ba canh cua mot tam giac');
readln;
end.
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,m;
int main()
{
cin>>n>>m;
for (i=1; i<=n; i++)
{
for (j=1; j<=m; j++)
{
if (i==1 || j==1|| i==n|| j==m) cout<<"*";
else cout<<" ";
}
cout<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],b[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
dem=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
dem++;
b[dem]=a[i];
}
for (i=1; i<=dem; i++) cout<<b[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=dem; i++) t+=b[i];
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) if (n%i==0) cout<<i<<" ";
return 0;
}
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]='H' then inc(dem);
writeln(dem);
readln;
end.
const fi='dl.dat';
fo='kq.dat';
var f1,f2:text;
a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if (a[i] mod 6=0) then t1:=t1+a[i];
if (a[i] mod 9=0) and (a[i] mod 2<>0) then t2:=t2+a[i];
end;
writeln(f2,dem1,' ',dem2);
writeln(f2,t1);
writeln(f2,t2);
close(f1);
close(f2);
end.
const fi='dl.dat';
fo='kq.dat';
var f1,f2:text;
a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if (a[i] mod 6=0) then t1:=t1+a[i];
if (a[i] mod 9=0) and (a[i] mod 2<>0) then t2:=t2+a[i]
end
writeln(f2,dem1,' ',dem2)
writeln(f2,t1)
writeln(f2,t2)
close(f1)
close(f2)
;-;
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
if a[i] mod 3=0 then write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
writeln('Cac phan tu chan la: ');
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
writeln;
writeln('Cac phan tu co chi so le la: ');
for i:=1 to n do
if i mod 2=1 then write(a[i]:4);
readln;
end.
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[10],i;
bool kt;
int main()
{
for (i=1; i<=10; i++) cin>>a[i];
kt=true;
for (i=1; i<=9; i++) if (a[i]>a[i+1]) kt=false;
if (kt==true) cout<<"YES";
else cout<<"NO";
return 0;
}
Program HOC24;
const fi='cau2.inp';
fo='cau2.out';
var dt,a,b,c: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
viết bằng c++ ạ