fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int error()
  7. {
  8. cout << "Error ";
  9. return 0;
  10. }
  11.  
  12. void f1(int a, int b, int c)
  13. {
  14. if (cout << "1", a > b) throw error();
  15. if (cout << "2", b > c) throw error();
  16. if (cout << "3", a < c) throw error();
  17. cout << "All right 1 ";
  18. }
  19.  
  20. void f2(int a, int b, int c)
  21. {
  22. if ((cout << "1", a > b) || (cout << "2", b > c) || (cout << "3", a < c)) throw error();
  23. cout << "All right 2 ";
  24. }
  25.  
  26.  
  27. int main(int argc, const char * argv[])
  28. {
  29. for(int a = 1; a <= 3; ++a)
  30. {
  31. for(int b = 1; b <= 3; ++b)
  32. {
  33. for(int c = 1; c <= 3; ++c)
  34. {
  35. cout << a << b << c << ": ";
  36. try
  37. {
  38. f1(a,b,c);
  39. }
  40. catch(...) {}
  41. try
  42. {
  43. f2(a,b,c);
  44. }
  45. catch(...) {}
  46. cout << endl;
  47. }
  48. }
  49. }
  50. }
  51.  
  52.  
Success #stdin #stdout 0s 4500KB
stdin
Standard input is empty
stdout
111:  123All right 1   123All right 2   
112:  123Error  123Error  
113:  123Error  123Error  
121:  12Error  12Error  
122:  123Error  123Error  
123:  123Error  123Error  
131:  12Error  12Error  
132:  12Error  12Error  
133:  123Error  123Error  
211:  1Error  1Error  
212:  1Error  1Error  
213:  1Error  1Error  
221:  12Error  12Error  
222:  123All right 1   123All right 2   
223:  123Error  123Error  
231:  12Error  12Error  
232:  12Error  12Error  
233:  123Error  123Error  
311:  1Error  1Error  
312:  1Error  1Error  
313:  1Error  1Error  
321:  1Error  1Error  
322:  1Error  1Error  
323:  1Error  1Error  
331:  12Error  12Error  
332:  12Error  12Error  
333:  123All right 1   123All right 2