A: Dongting Lake is the largest, the Hongze lake is the smallest, the third.
B: Hongze Lake is the largest, Dongting lake is the smallest, Poyang Lake second, Taihu third.
C: The Hongze lake is the smallest and the third.
Ding: Poyang Lake is the largest, Taihu Lake, the second, Dongting Lake third.
Given the size of each lake, it is known that each person is only right, and if you let the computer use this information to judge the university rankings of four lakes, you also need to have logical reasoning skills.
The code is as follows:
#include <iostream>using namespace Std;int main () {int dt,hz,py,th; BOOL Flag=false; for (dt=1; dt<=4&&!flag; ++DT) {for (hz=1; hz<=4&&!flag; ++hz) {if (dt==hz) continue; else for (Py=1; py<=4&&!flag; ++py) {if (py==dt| | PY==HZ) continue; else {th=10-dt-py-hz; if ((dt==1) + (hz==4) + (py==3)) ==1&& ((hz==1) + (dt==4) + (py==2) + (th==3)) ==1 && (( hz==4) + (dt==3)) ==1 && ((py==1) + (th==4) + (hz==2) + (dt==3)) ==1) {Cou t<< "Dongting Lake" <<DT<< "name \ n Hongze Lake," <<HZ<< "name \ Na ' an" <<PY<< "Lake Taihu First" <<TH< < "name \ n"; Flag=true; } } } } } return 0;}
Operation Result:
Four Lake Problems (enumeration method)