С++14
Код:
#include <iostream>#include <iomanip>#include <string>#include <algorithm> size_t count_char(const std::string& number, char c) { return std::count(number.begin(), number.end(), c);} bool is_it_more_than(const std::string& number, char a, char b) { return count_char(number, a) > count_char(number, b);}int main() { long long k = 4353621ll; char a = '3'; char b = '4'; std::string number = std::to_string(k); std::cout << "Number is " << number << std::endl; std::cout << "a = " << a << std::endl; std::cout << "b = " << b << std::endl; std::cout << "Does a appear in Number more often than b: " << std::boolalpha << is_it_more_than(number, a, b) << std::endl; return 0;}
var a,b,c,d:real;
c1, c2, z1, z2:real;
begin
write('Введи числитель первой дроби: '); read(a);
write('Введи знаменатель первой дроби: '); read(b);
write('Введи числитель второй дроби: '); read(c);
write('Введи знаменатель второй дроби: '); read(d);
write(a + ' / ' + b + ' + ' + c + ' / ' + d + ' = ');
if(b = d) then begin
c1 := a + c;
write(c1 + ' / ' + b);
End else Begin
z1 := b * d;
c1 := (z1 / b) * a;
c2 := (z1 / d) * c;
z2 := c1 + c2;
write(z2 + ' / ' + z1);
end;
end.