Răspuns:
3.
#include<iostream>
using namespace std;
int x,k,s;
int main()
{
cin>>x>>k;
while(x)
{
if(x%10%k!=0)s+=x%10;
x/=10;
}
cout<<s;
}
4.
#include<iostream>
#include<fstream>
using namespace std;
ifstream fcout("interval.txt");
int x,k,s;
int main()
{
cin>>x;
if(x!=0)
{
while(x)
{
if(x/100==0 && x/10!=0)k++;
cin>>x;
}
fcout<<k;
}
else fcout<<0;
}
Explicație: