#include <iostream>
#include <fstream>
#include <time.h>
using namespace std;
fstream inf;
int Matrix[50][50];
int B[1000] = { 12,104,81,1964,5,22 };
int i, j, n;
int counter;
float MidNeg, MidPoz;
int Negativ, Pozitiv;
int sumNeg, sumPoz;
int znak;
char z;
int NuM, maxNuM;
int main()
{
setlocale(LC_ALL, ".1251");
system("color 1f");
cout << "\n\tПрактична работа. ТЕМА: Обробка числових даних. \n";
cout << "\n\n\tВведiть розряднiсть чисел N="; cin >> NuM;
maxNuM = (int)pow(10, NuM) - 1;
cout << "\n\n\tНайбiльше з чисел: " << maxNuM;
cout << "\n\n\tОбранi елементи:\n\n\t";
counter = 0;
int od, ds, st, ts, dts;
if (maxNuM == 9 || maxNuM == 99 || maxNuM == 999 ||
maxNuM == 9999 || maxNuM == 99999)
for (int k = 1; k <= maxNuM; k++)
{
if (k > 9999 && k < 100000)
{
od = k % 10;
ds = k % 100 / 10;
if (od == ds) continue;
st = k % 1000 / 100;
if ((st == od) || (st == ds)) continue;
ts = k % 10000 / 1000;
if ((ts == st) || (ts == od) || (ts == ds)) continue;
dts = k / 10000;
if ((dts == ts) || (dts == st) || (dts == od) || (dts == ds)) continue;
else {
printf("%8i", k);
counter++;
}
}
else if (k > 999 && k < 10000)
{
od = k % 10;
ds = k % 100 / 10;
if (od == ds) continue;
st = k % 1000 / 100;
if ((st == od) || (st == ds)) continue;
ts = k / 1000;
if ((ts == st) || (ts == od) || (ts == ds)) continue;
else {
printf("%8i", k);
counter++;
}
}
else if (k > 99 && k < 1000)
{
od = k % 10;
ds = k % 100 / 10;
if (od == ds) continue;
st = k / 100;
if ((st == od) || (st == ds)) continue;
else {
printf("%8i", k);
counter++;
}
}
else if (k > 9 && k < 100)
{
od = k % 10;
ds = k / 10;
if (od == ds) continue;
else {
printf("%8i", k);
counter++;
}
}
else if (k<10)
{
printf("%8i", k);
counter++;
}
}
cout << "\n\n\tЗнайдено " << counter << " чисел.";
cout << endl << endl << "\t";
system("pause");
return 0;
}
Якщо ви помітили помилку чи неточність, виділіть фрагмент тексту та натисніть Ctrl+Enter.