1
0
forked from kalmar/DALGLI0
DALGLI0/main.cpp

107 lines
2.3 KiB
C++
Raw Normal View History

2018-05-30 23:36:54 +02:00
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <conio.h>
#include <math.h>
using namespace std;
void El_Odwracalne(int n){
int mod = 1 % n;
for(int i = 1;i <= n; i++){
for(int j=1; j<=n; j++){
if((i*j)%n == mod){
cout<<i<<" ";
}
}
}
}
void Dz_Zera(int n){
vector<int> vec;
cout<<"0 ";
for(int i=1; i<n; i++){
for(int j=1; j<n; j++){
if((i*j) % n == 0){
vec.push_back(i);
}
}
}
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
for(int k=0; k<vec.size(); ++k)
cout<<vec[k]<< " ";
}
void El_Nilpotentne(int n){
int wynik=1;
vector<int> vec;
cout<<"0 ";
for(int i=2; i<n-1; i++){
for(int j=1; j<n; j++){
wynik = (int) pow(i,j);
if(wynik % n == 0)
cout<<i<<" ";
vec.push_back(i);
i++;
}
}
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
for(int k=0; k<vec.size(); ++k)
cout<<vec[k]<< " ";
}
void El_Idempotentne(int n){
int wynik;
cout<<"0 ";
for(int i=1; i<n; i++){
wynik = i*i;
if(wynik % n == i)
cout<<i<<" ";
}
}
int main()
{
do {
int n;
cout<<"Wpisz liczbe n: ";
cin>>n;
cout<<endl;
while(n>1000){
cout<<"Wpisz liczbe mniejsza od 1000: "<<endl;
cin>>n;
}
cout<<"Elementy odwracalne "<<n<<" to: ";
El_Odwracalne(n);
cout<<endl<<endl;
cout<<"Dzielniki zera "<<n<<" to: ";
Dz_Zera(n);
cout<<endl<<endl;
cout<<"Elementy nilpotentne "<<n<<" to: ";
El_Nilpotentne(n);
cout<<endl<<endl;
cout<<"Elementy idempotentne "<<n<<" to: ";
El_Idempotentne(n);
cout<<endl<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"Wcisnij ESC aby wyjsc | Wcisnij inny klawisz aby kontynuowac"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
}
while (getch() != 27);
}