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.
Câu 1:
program an_danh;
uses crt;
var tong,n,i: integer;
begin
clrscr;
tong:= 0;
write('Nhap n: ');readln(n);
for i:= 1 to n do tong:= tong + i;
write('Tong tu 1 den ',n,' = ',tong);
readln
end.
Câu 2:
program an_danh;
uses crt;
var tong,i: integer;
begin
clrscr;
tong:= 0;
for i:= 1 to 200 do
tong:= tong + i;
write('Tong 200 so nguyen dau tien: ',tong);
readln
end.
Câu 3:
program an_danh;
uses crt;
var tich:real;
i:integer;
begin
clrscr;
tich:= 1;
for i:= 1 to 30 do
tich:= tich * i;
write('Tich 30 so nguyen dau tien: ',tich:0:0);
readln
end.
Câu 4:
program an_danh;
uses crt;
var gt:real;
i,n: integer;
begin
clrscr;
write('Nhap n: ');readln(n);
gt:= 1;
for i:= 1 to n do gt:= gt * i;
write(n,'! = ',gt:0:0);
readln
end.
Câu 5:
program an_danh;
uses crt;
var x,n,i:integer;
kq:real;
begin
clrscr;
write('Nhap x: ');readln(x);
write('Nhap n: ');readln(n);
kq:= x;
for i:= 2 to n do kq:= kq * x;
write(x,' mu ',n,' = ',kq:0:0);
readln
end.
Câu 1:
uses crt;
var n,i,s:longint;
begin
clrscr;
write('n='); readln(n);
s:=0;
for i:=1 to n do
s:=s+i;
writeln('tong S=',s);
readln;
end.
Câu 2:
uses crt;
var i,s:longint;
begin
clrscr;
s:=0;
for i:=1 to 200 do
s:=s+i;
writeln('tong 200 so nguyen dau tien la: ',s);
readln;
end.
Câu 3:
uses crt;
var i:integer;
s:real;
begin
clrscr;
s:=1;
for i:=1 to 30 do
s:=s*i;
writeln(s:4:0);
readln;
end.
Câu 4:
uses crt;
var n:qword;
i:integer;
s:real;
begin
clrscr;
write('n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(n,'!=',s:4:0);
readln;
end.
Câu 5:
uses crt;
var n,x,i:longint;
lt:real;
begin
clrscr;
write('co so x='); readln(x);
write('so mu n='); readln(n);
if n>=0 then
begin
lt:=1;
for i:=1 to n do
lt:=lt*x;
writeln(x,'^',n,'=',lt:4:0);
end
else writeln('vui long nhap lai so mu khong am');
readln;
end.
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
long t=0; int i,j;
for (i=2; i<=n; i++){
int c=0;
for (j=2; j<i; j++)
if (i%j==0) c++;
if (c==0) t=t+i;
}
printf("%d",t);
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[10],n,i,t;
int main()
{
n=0;
do
{
cin>>a[i];
}
while ((a[i]==0) or (n==10));
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0) t=t+a[i];
cout<<t;
return 0;
}
bạn có thể code bằng c căn bản chỉ dùng printf while vs for thôi đc ko bạn
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
if ((n>10) and (n<70))
{
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t=t+i;
cout<<t;
}
else cout<<"Nhap lai";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;
cin>>n;
if (n%2==0) cout<<n<<" la so chan"<<endl;
else cout<<n<<" la so le"<<endl;
if (n<0) cout<<n<<" la so am";
else cout<<n<<" la so khong am";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n,i,t1=0,t2=0;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
{
if (i%2==0) t1+=i;
else t2+=i;
}
cout<<t1<<endl;
cout<<t2<<endl;
cout<<"hieu tuyet doi la:"<<abs(t2-t1);
}