fork(1) download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3.  
  4. int main() {
  5. int intNum = 0;
  6. int example=42;
  7. cin >> intNum;
  8. while (intNum != example) {
  9. if (intNum > example){
  10. cout<<intNum<<"猜大了"<<endl;
  11. cin>>intNum;
  12. }
  13. if(intNum<example){
  14. cout<<intNum<<"猜小了"<<endl;
  15. cin>>intNum;
  16. }
  17. }
  18. cout<<intNum<<"猜对了";
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5272KB
stdin
1
2

42
42
stdout
1猜小了
2猜小了
42猜对了