mọi người ơi giúp mình với mình đang cần gấp ạ
Viết CT nhập mảng nguyên gồm N phần tử rồi ghi vào tệp KQ.txt ( lưu trong ổ đĩa D )
trên free Pascal IDE
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.
Var a:array[1..100] of integer;
i,s:integer;
Begin
For i:=1 to 100 do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
If a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
int n,x,i,cnt,res;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) res++;
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int gh=1000;
int n,x,i,cnt,res,dem[gh];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) { res++; dem[res]=x;}
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
cout<<"\n"<<"cac phan tu do la: "<<"\n";
for(i=1;i<=res;i++)
cout<<dem[i]<<" ";
return 0;
}
// đây mới đúng mik đọc lỗi đề nha bạn!!
1:
uses crt;
const fi='songuyen.doc';
var i:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
for i:=1 to 10 do write(f1,i:4);
close(f1);
readln;
end.
Program HOC24;
var a: array[1..32000] of integer;
ucln,i,n,ucln1: integer;
function uc(x,y: integer): integer;
var tg: integer;
begin
while y<>0 do
begin
tg:=x mod y;
x:=y;
y:=tg;
end;
uc:=x;
end;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
ucln1:=uc(a[1],a[2]);
for i:=3 to n do ucln:=uc(ucln1,a[i]);
write('Uoc chung lon nhat cua day so la: ',ucln);
readln
end.
program XuatSoChan;
uses crt;
const
Max_N = 20;
type
MangSoNguyen = array [1..Max_N] of integer;
var
A: MangSoNguyen;
i, n: integer;
begin
clrscr;
write('Nhap so luong phan tu cua mang: ');
readln(n);
writeln('Nhap cac phan tu vao mang:');
for i := 1 to n do
begin
write('A[', i, ']: ');
readln(A[i]);
end;
writeln('Cac so chan trong mang la:');
for i := 1 to n do
begin
if A[i] mod 2 = 0 then
writeln(A[i]);
end;
readln;
end.
uses crt;
var i,j,m:integer;
t:longint;
a:array[1..100,1..100]of integer;
begin
clrscr;
write('nhap m:');readln(m);
for i:=1 to m do
for j:=1 to m do
begin
write('a[',i,',',j,']=');readln(a[i,j]);
end;
clrscr;
writeln('ma tran da nhap la:');
for i:=1 to m do
begin
for j:=1 to m do
write(a[i,j]:5);writeln;
end;
i:=1;j:=1;
while i<=m do
begin
t:=t+a[i,j];
inc(i);inc(j);
end;
writeln('tong cac phan tu nam tren duong cheo chinh la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long dem,x,n,i,t;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0)
{
dem++;
t+=x;
}
}
cout<<dem<<" "<<t;
return 0;
}
uses crt;
const fo='data.txt';
var f1:text;
a:array[1..10]of integer;
i,n:integer;
begin
clrscr;
assign(f1,fo); rewrite(f1);
n:=10;
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(f1,a[i]:4);
close(f1);
readln;
end.
Program HOC24;
var n,i: integer;
a: array[1..32000] of integer;
procedure out;
begin
assign(f,'KQ.txt');
rewrite(f);
for i:=1 to n do write(f,a[i],' ');
close(f);
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
out;
readln
end.