Bài 3: Người phương Đông quan niệm số đẹp là các số tự nhiên chỉ chứa hai số 6 hoặc 8. Ví dụ: 6, 8, 66, 68, 886, …. là những số đẹp, 468, 728… không phải là những số đẹp. Cho số nguyên dương N (1≤N≤1000), kiểm tra xem N có phải là số đẹp không? Nếu N là số đẹp thì đưa ra thông báo là “YES”, không thì đưa ra thông báo “NO” viết bằng c++ giúp iem với ạ
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;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==1)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==0)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
double r;
int main()
{
cin>>r;
cout<<2*r*pi<<endl;
cout<<r*r*pi;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
double a,b,c,tb;
int main()
{
cin>>a>>b>>c;
tb=(a+b+c)/3;
cout<<fixed<<setprecision(1)<<tb<<endl;
if (tb>=8) cout<<"Gioi";
else if ((6.5<=tb) and (tb<8)) cout<<"Kha";
else if ((5<=tb) and (tb<=6.5)) cout<<"Trung Binh";
else cout<<"Chua dat";
return 0;
}
b:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
}
cout<<fixed<<setprecision(2)<<t*1.0/(n*1.0);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,t;
int main()
{
cin>>n;
t=0;
while (n!=0)
{
if ((n%3==0) or (n%5==0)) t=t+n;
cin>>n;
}
cout<<t;
return 0;
}
}
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i;
bool kt;
int main()
{
cin>>st;
d=st.length();
kt=true;
for (i=0; i<=d-1; i++)
if ((st[i]!='6') and (st[i]!='8')) kt=false;
if (kt==true) cout<<"YES";
else cout<<"NO";
return 0;
}