Những câu hỏi liên quan
Nguyễn Cảnh Hùng
Xem chi tiết
Đỗ Ngọc Trinh
25 tháng 7 2017 lúc 9:38

- Xác định bài toán (0,5đ)

Input: Nhập N và dãy  a 1 , a 2 , . . . , a n

Output: Đưa ra kết quả tổng S

- Thuật toán (1,75đ):

Bước 1: Nhập N và  a 1 , a 2 , . . . , a n

Bước 2: S ← 0; i ← 1

Bước 3: Nếu i >Nthì đưa ra S rồi kết thúc

Bước 4: Nếu ai⟨0 thì S ←S+ a i 2

Bước 5: i ← i + 1 và quay lại Bước 3

Bình luận (0)
Huỳnh Kim Phương
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 2 2023 lúc 21:08

uses crt;

var i,n,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n do t:=t+i*i;

write(t);

readln;

end.

Bình luận (1)
Lâm Khả Doanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2023 lúc 22:28

1:

uses crt;

var n,i,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n do

t:=t+i*i;

write(t);

readln;

end.

Bình luận (0)
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:21

2

program bt2;

var i,n,t:integer;

begin

readln(n);

s:=0;

for i:=1 to n do

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

readln;

end.

Bình luận (0)
uyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 12 2021 lúc 23:58

#include <bits/stdc++.h>

using namespace std;

long long a,b,c,d;

int main()

{

cin>>a>>b>>c>>d;

cout<<a+b+c+d;

return 0;

}

Bình luận (0)
dswat monkey
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 1 2022 lúc 9:36

c: 

#include <bits/stdc++.h>

using namespace std;

long long ln,i,n,x;

int main()

{

cin>>n;

ln=LLONG_MIN;

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

{

cin>>x;

ln=max(ln,x);

}

cout<<ln;

return 0;

}

Bình luận (0)
foxbi
Xem chi tiết
Thanh Phong (9A5)
18 tháng 3 2023 lúc 8:11

Uses crt;

var n,i,s: integer;

begin clrscr;

readln(n);

for i:=1 to n do s:=s+1/i;

writeln(s);

readln;

end.

Bình luận (0)
2k15
Xem chi tiết
Gia Huy
1 tháng 7 2023 lúc 7:11

```cpp
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
int n;
std::cout << "Enter the number of integers (n < 10^5): ";
std::cin >> n;

std::vector&lt;int&gt; numbers(n); std::cout &lt;&lt; &quot;Enter &quot; &lt;&lt; n &lt;&lt; &quot; integers: &quot;; for (int i = 0; i &lt; n; ++i) { std::cin &gt;&gt; numbers[i]; } int sumOfOdd = 0; for (int i = 0; i &lt; n; ++i) { if (numbers[i] % 2 != 0) { sumOfOdd += numbers[i]; } } std::sort(numbers.begin(), numbers.end()); std::cout &lt;&lt; &quot;Sum of odd integers: &quot; &lt;&lt; sumOfOdd &lt;&lt; std::endl; std::cout &lt;&lt; &quot;Sorted sequence: &quot;; for (int i = 0; i &lt; n; ++i) { std::cout &lt;&lt; numbers[i] &lt;&lt; &quot; &quot;; } std::cout &lt;&lt; std::endl; return 0;

}
```

Bình luận (0)
gia linh
Xem chi tiết
Trần Việt Long
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 20:43

Sửa đề: S=1/1+1/2+1/3+...+1/n

uses crt;

var n,i:integer;

s:real;

begin

clrscr;

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

s:=0;

for i:=1 to n do 

  s:=s+1/i;

writeln(s:4:2);

readln;

end.

Bình luận (0)
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 22:11

program tong;

uses crt;

var n,i:integer;

t:longint;

begin

clrscr;

write('nhap n:'); readln(n);

t:=0;

for i:=1 to n do 

  t:=t+1/i;

writeln(t);

readln;

end.

Bình luận (0)
Tran Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2020 lúc 21:10

uses crt;

var n,i,s:integer;

begin

clrscr;

repeat

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

until n>0;

s:=0;

for i:=1 to n do

s:=s+i;

writeln('Ket qua la: ',s);

readln;

end.

Bình luận (0)