K
Khách

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;

const fi='kq.txt';

var a:array[1..15]of real;

i,n:integer;

f1:text;

begin

clrscr;

n:=15;

for i:=1 to n do readln(a[i]);

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

for i:=1 to n do 

  begin

 if (i mod 5=0) then writeln(f1)

else write(f1,a[i],' ');

end;

close(f1);

readln;

end.

uses crt;

const fi='kq.txt';

var a:array[1..10]of integer;

i,n:integer;

f1:text;

begin

clrscr;

n:=10;

for i:=1 to n do readln(a[i]);

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

for i:=1 to n do 

  begin

if (n%5<>0) then write(f1,a[i]:4);

else writeln(f1);

end;

close(f1);

readln;

end.

uses crt;

const fi='kq.txt';

var a:array[1..10]of integer;

i,n,dem:integer;

f1:text;

begin

clrscr;

n:=10;

for i:=1 to n do readln(a[i]);

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

for i:=1 to n do write(f1,a[i]:4);

writeln(f1);

dem:=0;

for i:=1 to n do  if a[i]>0 then dem:=dem+1;

writeln(f1,dem);

close(f1);

readln;

end.

QT
Quoc Tran Anh Le
Giáo viên
23 tháng 8 2023

# Nhập dãy số từ bàn phím
lst = list(map(int, input("Nhập dãy số cách nhau bởi dấu cách: ").split()))

# Sắp xếp dãy số theo thuật toán sắp xếp chọn
for i in range(len(lst)):
   min_idx = i
   for j in range(i+1, len(lst)):
       if lst[j] < lst[min_idx]:
           min_idx = j
   lst[i], lst[min_idx] = lst[min_idx], lst[i]

# In kết quả ra màn hình
print("Dãy số đã sắp xếp:", lst)

16 tháng 1 2022

const fi='dulieu.txt';
fo='ketqua.txt';
var i,t:integer;
f1,f2:text;
a:array[1..9]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
t:=0;
for i:=1 to 9 do
begin
read(f1,a[i]);
t:=t+a[i];
end;
writeln(f2,t);
close(f1);
close(f2);
end.

16 tháng 1 2022

s

const fi='dataln.txt';

fo='dataout.txt';

var f1,f2:text;

x,i,t:integer;

begin

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

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

t:=0;

for i:=1 to 24 do 

begin

read(f1,x);

t:=t+x;

end;

writeln(f2,t);

close(f1);

close(f2);

end.

#include <bits/stdc++.h>

using namespace std;

long long x,y;

int main()

{

cin>>x>>y;

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

cout<<x+y<<endl;

cout<<x-y<<endl;

cout<<x*y<<endl;

cout<<fixed<<setprecision(2)<<(x*1.0)/(y*1.0);

return 0;

}

23 tháng 8 2023

a)

m = int(input("Nhập số dòng của ma trận: "))

n = int(input("Nhập số cột của ma trận: "))

# Khởi tạo ma trận A với kích thước m x n

A = []

for i in range(m):

  row = list(map(int, input(f"Nhập dòng thứ {i+1} (gồm {n} số cách nhau bởi dấu cách): ").split()))

  A.append(row)

# In ma trận A ra màn hình

print("Ma trận A:")

for row in A:

  print(*row)

# Tính tổng các phần tử trong ma trận A

total = 0

for row in A:

  total += sum(row)

print("Tổng các phần tử trong ma trận A là:", total)

b)

# Tìm dòng có tổng các phần tử lớn nhất

max_sum = max(sum(row) for row in A)

print("Dòng có tổng các phần tử lớn nhất là:")

for i, row in enumerate(A):

  if sum(row) == max_sum:

  print(f"Dòng thứ {i+1}: {row}")

c)

Tìm các giá trị phân biệt trong ma trận A

  distinct_values = set()

for row in A:

distinct_values.update(set(row))

# In các giá trị phân biệt ra màn hình

print("Các giá trị phân biệt trong ma trận:")

print(*distinct_values)

d)

k=int(input("nhập số cần tìm"))

l=0

for i in range(m):

  for j in range(n):

   if k==a[i][j]:

    l=l+1

    print('xuất hiện ở các vị trí',i,j)

print('số',k,' xuất hiện',l,' lần')