K
Khách

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,a[10000];

//chuongtrinhcon

bool ktnt(long long n)

{

for (int i=2; i*i<=n; i++)

if (n%i==0) return(false);

return(true);

}

//chuongtrinhchinh

int main()

{

cin>>n;

dem=0;

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

{

cin>>a[i];

if (a[i]>1 && (ktnt(a[i])==true)) dem++;

}

cout<<dem;

return 0;

}

D
datcoder
Giáo viên
26 tháng 3

#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;

}

D
datcoder
Giáo viên
9 tháng 1

Bạn trình bày lại đề bài rõ hơn nha, đề đọc rất khó hiểu ấy.

D
datcoder
Giáo viên
10 tháng 10 2023

Bài 6:

#include <bits/stdc++.h>

using namespace std;

int main () {

int n;

cin >> n;

int p=n/60;

int s=n%60;

if (p<60) {

if (p<10) {

if (s<10) cout <<"00:0" << p << ":0" << s; else cout <<"00:0" << p << ":" << s;} else

if ((p>=10) and (p<60)) {if (s<10) cout << "00:" << p << ":0" << s;

else cout << "00:" << p << ":" << s;}}

if (p>=60) {

int h = p/60;

p = p%60;

if (h<10) { if (p<10) {

if (s<10) cout << "0" << h << ":" << "0" << p <<":0" <<s;

else cout << "0" << h << ":" << "0" << p <<":" <<s; } else {

if (s<10) cout << "0" << h << ":" << p <<":0" <<s;

else cout << "0" << h << ":" << p <<":" <<s;} } else {

if (p<10) { if (s<10) cout << h << ":" << "0" << p <<":0" <<s;

else cout << h << ":" << "0" << p <<":" <<s; } else {

if (s<10) cout << h << ":" << p <<":0" <<s;

else cout << h << ":" << p <<":" <<s;} } }

return 0;

}

D
datcoder
Giáo viên
11 tháng 10 2023

Bài 5:

#include <bits/stdc++.h>

using namespace std;

int main () {

int n;

cin >> n;

int m=n;

int t100 = n/100;

n = n - t100 * 100;

int t50 = n/50;

n = n - t50*50;

int t20 = n/20;

n = n - t20*20;

int t10 = n/10;

n = n - t10*10;

int t5 = n/5;

n = n - t5*5;

int t2 = n/2;

n = n - t2*2;

int t1 = n;

if (m>=100) cout << t100 << " to menh gia 100" << endl;

if (t50!=0) cout << t50<< " to menh gia 50" << endl;

if (t20!=0) cout << t20<< " to menh gia 20" << endl;

if (t10!=0) cout << t10<< " to menh gia 10" << endl;

if (t5!=0) cout << t5<< " to menh gia 5" << endl;

if (t2!=0) cout << t2<< " to menh gia 2" << endl;

if (t1!=0) cout << t50<< " to menh gia 1" << endl;

return 0;

}

13 tháng 7 2021
Code:#include <stdio.h> struct phanso {int tu;int mau;}; int ucln(int a, int b) {while(a!=b){if(a>b)a=a-b;elseb=b-a;}return a;} struct phanso tg(struct phanso a) {int c = ucln(a.tu, a.mau);a.tu /= c;a.mau /= c;return a;} struct phanso tong(struct phanso a, struct phanso b) {struct phanso s;s.tu = (a.tu * b.mau) + (b.tu * a.mau);s.mau = a.mau * b.mau;return s;} main() {struct phanso ps[100];struct phanso s;int n, x = 0, maxnum;double gtps[100], max;unsigned int i;printf("Nhap n: "); scanf("%d", &n);for (i = 0; i < n; i++) {printf("Nhap tu so cua phan so so %d: ", i + 1); scanf("%d", &ps[i].tu);printf("Nhap mau so cua phan so so %d: ", i + 1); scanf("%d", &ps[i].mau);}s = ps[0];for (i = 1; i < n; i++) {s = tong(s, ps[i]);}printf("\n");printf("a) Tong: %d/%d\n", tg(s).tu, tg(s).mau);for (i = 0; i < n; i++) {if (ps[i].mau != tg(ps[i]).mau) {x += 1;}}printf("b) So phan so chua toi gian: %d\n", x);for (i = 0; i < n; i++) {gtps[i] = (double)ps[i].tu / (double)ps[i].mau;}max = gtps[0];for (i = 1; i < n; i++) {if (max < gtps[i]) {maxnum = i;max = gtps[i];}}printf("c) Phan so co gia tri lon nhat la: %d/%d", ps[maxnum].tu, ps[maxnum].mau);return 0;} Ảnh: