Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Hoàng Ngọc nhi
Xem chi tiết
Nguyễn Lê Phước Thịnh
6 tháng 4 2021 lúc 12:37

uses crt;

const fi='dulieu.txt'

var f1:text;

a,b,c:integer;

begin

clrscr;

assign(f1,fi); rewrite(f1);

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

write('Nhap c='); readln(c);

writeln(f1,a);

writeln(f1,b);

writeln(f1,c);

close(f1);

end.

Nguyễn Quang Trung
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 2 2021 lúc 21:19

const fi='dulieu.txt'

fo='ketqua.txt'

var f1,f2:text;

a:array[1..100]of integer;

i,n:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do

begin

inc(n);

read(f1,a[n]);

end;

for i:=1 to n do 

  if a[i] mod 3=0 then write(f2,a[i]:4);

close(f1);

close(f2);

end.

Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 23:00

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

freopen("dulieu.txt","r",stdin);

freopen("uot.txt","w",stdout);

cin>>n;

t=0;

for (i=1; i<=n; i++)

if (i%2==0) t+=i;

cout<<t;

return 0;

}

Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
25 tháng 6 2018 lúc 3:32

Var f1, f2: text;

  Tong, m, n, i: integer;

Begin

  assign(f1, ‘DULIEU.TXT’);

  reset(f1);

  assign(f2, ‘KETQUA’);

  rewrite(f2);

  Tong;= 0;

  read(f1, m, n);

  for i:= m to n do

  if i mod 2 = 1 then Tong:= Tong+i;

  write(f2, Tong);

  close(f1);

  close(f2);

End.

Kiên Tạ
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 20:46

const fi='dulieu.txt'     

fo='ketqua.txt'

var f1,f2:text;   

a,b,c,d:array[1..100]of integer;   

i,n,dem,dem1:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do 

begin     

n:=n+1;     

readln(f1,a[n],b[n]); 

end;

dem:=0;

dem1:=0;

for i:=1 to n do 

if a[i]>b[i] then     

begin       

inc(dem);       

inc(dem1);       

c[dem]:=a[i];       

d[dem]:=b[i];     

end 

else begin         

inc(dem);         

inc(dem1);         

c[dem]:=b[i];         

d[dem]:=a[i];       

end;

for i:=1 to dem do 

write(f2,c[i]:4);

writeln(f2);

for i:=1 to dem1 do 

write(f2,d[i]:4);

close(f1);

close(f2);

end.

agvdh
Xem chi tiết
35.Nguyễn Anh Tú
Xem chi tiết
Vũ Hữu Đại
Xem chi tiết
Thanh Đình Lê
17 tháng 4 2023 lúc 22:54

Đây là một bài tập lập trình, dưới đây là đoạn mã Python để thực hiện các yêu cầu trong bài tập:

`python
import os

Tạo tệp DEBALDAT trong ổ đĩa D
with open('D:/DEBALDAT', 'w') as f:
data = input("Nhập dữ liệu: ")
f.write(data)

Đọc dữ liệu từ tệp DEBALDAT
with open('D:/DEBALDAT', 'r') as f:
data = f.read()

Tìm số nhỏ nhất và ghi vào tệp SONHONHAT.OUT
numbers = [int(x) for x in data if x.isdigit()]
min_number = min(numbers)
with open('D:/SONHONHAT.OUT', 'w') as f:
f.write(str(min_number))

Tính tổng các số chẵn và ghi vào tệp SOCHAN.OUT
even_numbers = [int(x) for x in data if x.isdigit() and int(x) % 2 == 0]
sum_even_numbers = sum(even_numbers)
with open('D:/SOCHAN.OUT', 'w') as f:
f.write(str(sum_even_numbers))

Đếm số kí tự dấu cách và ghi vào tệp DAUCACH.OUT
num_spaces = data.count(' ')
with open('D:/DAUCACH.OUT', 'w') as f:
f.write(str(num_spaces))

Xóa các kí tự dấu cách và ghi vào tệp KETQUA.OUT
data_without_spaces = data.replace(' ', '')
with open('D:/KETQUA.OUT', 'w') as f:
f.write(data_without_spaces)

Xóa tệp DEBALDAT
os.remove('D:/DEBALDAT')
`

Lưu ý: Đoạn mã này chỉ thực hiện được trên hệ điều hành Windows, nếu sử dụng hệ điều hành khác cần thay đổi đường dẫn ổ đĩa.

Phạm Tiến Vượng
Xem chi tiết