Cho tệp DULIEU.DAT chứa giá trị của a,x,n của dãy số S= 1 + x(a + 1 ) + x^2(a + 2) + ....+ x^n(a+n) với S>=10000. Tạo tệp KETQUA.DAT ghi giá trị tổng S với các cặp a,x tương ứng
Program HOC24;
const fi='DULIEU.DAT'
fo='KETQUA.DAT'
var a,x,n: integer;
s: longint;
function luythua(a,b: integer): longint;
var j,t: longint;
begin
t:=1;
for j:=1 to b do t:=t*a;
luythua:=t;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,x,n);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
s:=1;
for i:=1 to n do
s:=s+luythua(x,i)*(a+i);
write(f,s);
close(f);
end;
begin
ip;
out;
end.
const fi='dulieu.dat'
fo='ketqua.dat'
var f1,f2:text;
n,i,s:integer;
a:array[1..100]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
read(f1,a[n]);
end;
s:=0;
for i:=1 to n do
s:=s+a[i];
writeln(f2,s);
close(f1);
close(f2);
end.
Viết chương trình mở tệp Input.Txt đọc các giá trị phần tử của 2 mảng số nguyên A, B được viết trên 2 dòng (các giá trị phân cách bởi dấu cách) (Mỗi mảng gồm 10 phần tử)
Mở tệp Output.Txt ghi các giá trị phần tử của mảng C (tương ứng là tổng giá trị của phần tử A,B)
#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;
}
giả sử tệp "Dulieu.txt" có cấu trúc: Dòng 1 ghi 1 số nguyên N kiểu int; dòng 2 trở đi ghi dãy số thực A1, A2, ..., An. Yêu cầu đọc dữ liệu từ tệp, tính tổng các giá trị của dãy rồi xuất ra màn hình
uses crt;
const fi='dulieu.txt'
var f1:text;
a:array[1..100]of real;
t:real;
i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
close(f1);
readln;
end.
Cho tệp Dulieu.txt chứa các số nguyên, mỗi giá trị cách nhau một khoảng trống.Đọc từ tệp ra các giá trị gắn vào 2 biến a,b. Tính tổng a+b và ghi ra kết quả vào tệp ketqua.txt Giúp em với ạ, chiều nay là deadline rồi ạ, em cảm ơn nhiều!!!
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
freopen("dulieu.txt","r",stdout);
freopen("ketqua.txt","w",stdout);
cin>>a>>b;
cout<<a+b;
return 0;
}
cho dãy số nguyên gồm N phần tử,tính tổng các số dương và âm.So sánh giá trị tuyệt đối của tổng số dương và âm ghi kết quả vào tệp Mang.TXT
uses crt;
const fi='mang.txt'
var a:array[1..100]of integer;
i,n,t1,t2:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
t1:=t1+a[i];
end;
if a[i]<0 then
begin
t2:=t2+a[i];
end;
end;
writeln(f1,'Tong cac so duong la: ',t1);
writeln(f1,'Tong cac so am la: ',t2);
if abs(t1)>abs(t2) then writeln(f1,'Gia tri tuyet doi cua ',t1,' lon hon gia tri tuyet doi cua ',t2)
else if abs(t1)<abs(t2) then writeln(f1,'Gia tri tuyet doi cua ',t2,' lon hon gia tri tuyet doi cua ',t1)
else writeln(f1,'Gia tri tuyet doi cua ',t1,' bang gia tri tuyet doi cua ',t2);
close(f1);
end.
a) Tính \(y = {2^x}\) khi x lần lượt nhận các giá trị - 1; 0; 1. Với mỗi giá trị của x có bao nhiêu giá trị của \(y = {2^x}\) tương ứng?
b) Với những giá trị nào của x, biểu thức có nghĩa?
a: Khi x=-1 thì \(y=2^{-1}=\dfrac{1}{2}\)
Khi x=0 thì \(y=2^0=1\)
Khi x=1 thì \(y=2^1=2\)
Với mỗi giá trị của x thì chỉ có 1 giá trị 2x tương ứng
b: Biểu thức y=2x có nghĩa với mọi x
Bài 1 : Cho hàm số y=(m-3)x+4 . Với giá trị nào của m thì hàm số đồng biến, nghịch biến Bài 4: Cho hàm số y=(3-√2) x+1 a, Hàm số đồng biến hay nghịch biến? Vì sao? b, Tính các giá trị tương ứng của y khi x nhân các giá trị sau ; O, 1, √2, 3+√2, 3-√2
Bài 1:
Hàm số y=(m-3)x+4 đồng biến trên R khi m-3>0
=>m>3
Hàm số y=(m-3)x+4 nghịch biến trên R khi m-3<0
=>m<3
Bài 4:
a: Vì \(a=3-\sqrt{2}>0\)
nên hàm số \(y=\left(3-\sqrt{2}\right)x+1\) đồng biến trên R
b: Khi x=0 thì \(y=0\left(3-\sqrt{2}\right)+1=1\)
Khi x=1 thì \(y=\left(3-\sqrt{2}\right)\cdot1+1=3-\sqrt{2}+1=4-\sqrt{2}\)
Khi \(x=\sqrt{2}\) thì \(y=\left(3-\sqrt{2}\right)\cdot\sqrt{2}+1=3\sqrt{2}-2+1=3\sqrt{2}-1\)
Khi \(x=3+\sqrt{2}\) thì \(y=\left(3-\sqrt{2}\right)\left(3+\sqrt{2}\right)-1\)
=9-4-1
=9-5
=4
Khi \(x=3-\sqrt{2}\) thì \(y=\left(3-\sqrt{2}\right)^2-1\)
\(=11-6\sqrt{2}-1=10-6\sqrt{2}\)
Cho x và y là đại lượng tỉ lệ thuận .
y1 ; y2 là các giá trị của y tương ứng với x1;x2 của x
a, Tìm các giá trị của y tương ứng với x = x1+x2.
b, Tìm các giá trị của y tương ứng với x = -2/7.x1
c, Tìm các giá trị của y tương ứng với x = x1/x2.
Giúp mink với nha các bạn !!!!!!!!