Ôn tập cuối năm

TA

Giúp mình bài này với ạ?

NT
24 tháng 10 2021 lúc 0:34

#include <iostream>
#include <time.h>
using namespace std;
int main()
{
    int van,d,i,r,so;
    cout<<"Nhap so van:";
    cin>>van;
    d=0;
    for (i=1;i<=van;i++)
    {
        cout<<"Van thu "<<i<<endl;
        srand((int)time(0));
        r=rand() % (10+1-8);
        cout<<"Ban hay doan so:";
        cin>>so;
        cout<<"So cua may la "<<r<<endl;
        if (so==r)
        {
            cout<<"Ban da doan dung"<<endl;
            d=d+1;
        }
        else cout<<"Ban da doan sai"<<endl;
    }
    cout<<"So van dung la "<<d;
}

 

Bình luận (1)

Các câu hỏi tương tự
PN
Xem chi tiết
H24
Xem chi tiết
NT
Xem chi tiết
ZN
Xem chi tiết
H24
Xem chi tiết
H24
Xem chi tiết
LH
Xem chi tiết
H24
Xem chi tiết
TP
Xem chi tiết