№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; }
n, m, sum, i, j: Integer;
a: Array [1..10000] of Array [1..10000] of Integer;
BEGIN
Read(n, m);
For i := 1 to n do
For j := 1 to m do Read(a[i][j]);
For i := 1 to n do
For j := 1 to m do
If (a[i][j] > 0) then sum := sum + a[i][j];
Write(sum);
END.
Но для экономии времени и сил можно не создавать массив:
VAR
n, m, sum, el, i, j: Integer;
BEGIN
Read(n, m);
For i := 1 to n do
For j := 1 to m do begin
Read(el);
If (el > 0) then sum := sum + el;
End;
Write(sum);
END.
#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;
}