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.
#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;
}
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,s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++) s=s+i*i;
cout<<s;
return 0;
}
Var s,i,n:longint;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
s:=s+i*i;
Write('Tong la ',s);
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;
}
Câu 3:
#include <bits/stdc++.h>
using namepsace std;
double a,b,c,p,s;
int main()
{
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
Câu 3:
#include <bits/stdc++.h>
using namepsace std;
double a,b,c,p,s;
int main()
{
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
Câu 3:
#include <bits/stdc++.h>
using namepsace std;
double a,b,c,p,s;
int main()
{
cin>>a>>b>>c;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
#include <iostream>
using namespace std;
int main() {
float sd, td;
int muc1 = 1000, muc2 = 1500, muc3 = 2000;
cin >> sd;
if (sd <= 50) {
td = sd * muc1;
} else if (sd <= 100) {
td = 50 * muc1 + (sd - 50) * muc2;
} else {
td = 50 * muc1 + 50 * muc2 + (sd - 100) * muc3;
}
cout << td;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long t=0;
if (n<=50) cout << n*1000;
if ((n>50) and (n<=100) cout << 50*1000+(n-50)*1500;
if (n>=101) cout << 50*1000+50*1500+(n-100)*2000;
return 0;
}