1.Вывести все четырехзначные натуральные числа, сумма цифр которых равна N.
program myprog
integer n
read(*,*) j
do n=1000,9999
if (summa(n)==j) then
write(*,*) n
end if
end do
contains
integer function summa(i)
k=i
l=0
do while (k>0)
l=l+mod(k,10)
k=k/10
end do
summa=l
end function
end
3.Дана входная строка. Удалить из нее повторяющиеся символы без учета регистра. Прим.: пробел также является символом.
#include<iostream>
#include <string>
#include<math.h>
using namespace std;
int main() {
string a, c,c1;
int i = 0;
getline(cin,a);
do {
c = a[i];
c1 = c;
a.erase(i, 1);
if ((a.find(c) != -1) || (a.find((char)((int)(c1[0]) - 32)) != -1)) {
while (a.find(c) != -1) {
a.erase(a.find(c), 1);
i = 0;
}
while (a.find((char)((int)(c1[0]) - 32)) != -1) {
a.erase(a.find(c), 1);
i = 0;
}
}
else
{
a.insert(i, c);
i++;
}
} while (i != a.length());
cout << a << endl;
system("pause");
}