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.
const fi='input.txt';
fo='output.txt';
var f1,f2:text;
a,b:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b);
writeln(f2,a+b);
close(f1);
close(f2);
end.
#include <bits/stdc++.h>
using namespace std;
long long a[10],b[10],i,j;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
for (i=1; i<=10; i++) cin>>a[i];
for (j=1; j<=10; j++) cin>>b[j];
for (i=1; i<=10; i++)
cout<<a[i]+b[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
Var i,k,n,bk,tong: integer;
a: array[1..1000] of integer;
Begin
write('Nhap K: '); readln(k);
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
{câu a}
For i:=1 to n do
if a[i]=k then bk:=bk+1;
writeln('Co so phan tu bang k la:',k);
{câu b}
For i:=1 to n do
if a[i]=k then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('. Tong la:',tong);
readln
end.
uses crt;
var k,n,tong,d,i:longint;a:array[1..1000]of longint;
begin
clrscr;
write('n=');readln(n);
write('k=');readln(k);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
d:=0;
for i:=1 to n do if(a[i]=k)then inc(d);
writeln('so phan tu bang voi:',k,' la:',d);
write('cac so co vi tri bang voi:',k,' la:');
tong:=0;
for i:=1 to n do if(a[i]=k)then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('tong cua cac so bang voi:',k,' la:',tong);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[6],i,t,t1;
int main()
{
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
if (a[i]%2==0) t=t+a[i];
}
t1=0;
for (i=1; i<=n; i++)
if ((a[i]%2!=0) and (i%2==0)) t1=t1+a[i];
cout<<t<<endl;
cout<<t1;
return 0;
}
Câu 1:
uses crt;
const fi='nguon.txt';
var f1:text;
a,b,c:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
assign(f1,fi); rewrite(f1);
writeln(f1,a);
writeln(f1,b);
writeln(f1,c);
close(f1);
readln;
end.
Câu 2:
const fi='nguon.txt';
fo='kq.txt';
var f1,f2:text;
a,b,c,max,min:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a);
readln(f1,b);
readln(f1,c);
writeln(f2,(a+b+c)/3:4:2);
max:=a;
if max<b then max:=b;
if max<c then max:=c;
writeln(f2,max);
min:=a;
if min>b then min:=b;
if min>c then min:=c;
writeln(f2,min);
close(f1);
close(f2);
end.