Mình mới học class. mn xem code của mình thế này có được không?
#include <iostream>
using namespace std;
class vongtay{
private:
int *sovong_;
public:
void nhap(){
int n;
cin >> n;
sovong_ = &n;
}
void tinhsovongtay( ){
if (*sovong_ <= 7 )
cout << 7 - *sovong_ << " " << *sovong_;
else{
if ( (*sovong_ / 7) % 2 == 1 )
cout << (*sovong_ % 7) << " " << 7 - (*sovong_ % 7);
else
cout << 7 - (*sovong_ % 7) << " " << *sovong_ % 7;
}
}
};
int main()
{
vongtay test;
test.nhap();
test.tinhsovongtay( );
return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?