forked from kalmar/DALGLI0
Prześlij pliki do ''
This commit is contained in:
parent
aaa2f9fc43
commit
3ade316b64
106
main.cpp
Normal file
106
main.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user