Вычислить все простые делители целого числа
Версия от 16:03, 13 ноября 2008; Vovan (обсуждение | вклад) (Новая: #include "stdafx.h" #include <iostream> #include <stdio.h> #include <math.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { setlocale(LC_ALL,"Rus"); long dig, k, ...)
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{ setlocale(LC_ALL,"Rus");
long dig, k, tmp=NULL;
printf ("Введите число:"); scanf ("%ld", &dig);
printf ("Делители числа %ld : \n\n", dig);
for (k = 2; k <= abs(dig); k++)
if (dig % k ==0)
{ if (k!=tmp) printf("%ld\n",k);
tmp=k;
dig /= k;
k = 1;
}
system("pause");
return 0;
}