Răspuns :
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("a.txt");
ofstream out("b.txt");
int main(){
int a,b;
f >> a >> b;
//Partea I
int d,nr_div=1;
for(d=1;d<=a/2;d++) if(a%d==0) nr_div++;
out << nr_div << " ";
//Partea II :
int suma=0;
while(b){
suma += b%10;
b=b/10;
}
out << suma;
}
Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("a.txt");
ofstream g ("b.txt");
int main()
{
int a,b,i;
f>>a>>b;
g<<1<<" " ;
for(i=2;i<=a/2;i++)
if(a%i==0)
g<<i<<" ";
g<<a<<"\n";
int s=0;
while(b)
{
s+=b%10;
b/=10;
}
g<<s;
}
Explicație: