№1 #include <iostream> using namespace std; int main () { int a,b; cin >> a >> b; if (a<b) cout << a << endl; else if (a==b) cout << "a=b" << endl; else cout << b << endl; system ("PAUSE"); return 0; }
№2 #include <iostream> using namespace std; int main () { char ch1,ch2; int i1,i2; cin >> ch1 >> ch2; i1=ch1; i2=ch2; if (i1<=i2) cout << ch1 << ' ' << ch2 << endl; else cout << ch2 << ' ' << ch1 << endl; system ("PAUSE"); return 0; }
№3 #include <iostream> using namespace std; int main () { float p,q; cout << "p="; cin >> p; cout << "q="; cin >> q; cout << p-2*q << endl; system ("PAUSE"); return 0; }
трассировка цикла с предусловием:
k:=5 S:=5
k:=4 S:=9
k:=3 S:=12 > выход из цикла
ответ 12