Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- void cycleTrue(int aray[],int aSize);
- int digit(int [], int );
- int counter(int [], int );
- main () {
- int counter44;
- int arayLenght=0;
- cin>>arayLenght;
- int currentDigit;
- int myArray[arayLenght]{};
- cycleTrue(myArray, arayLenght);
- currentDigit=digit(myArray,arayLenght);
- counter44=counter(myArray,arayLenght);
- if(counter44!=1){
- for(int a=0;a<counter44;){
- ++a;
- cout<<currentDigit;
- if(a==counter44){
- break;
- } else {
- cout<<" ";
- }
- }
- } else {
- cout<<currentDigit;
- }
- return 0;
- }
- void cycleTrue(int aray[], int aSize){
- for(int a=0 ; a<aSize ; a++){
- int current=0;
- cin>> current;
- aray[a]=current;
- }
- }
- int counter(int array1[], int arrLenght1){
- int possitionCounter=1;
- int digitsCounter=1;
- int currentMax=0;
- bool validation=false;
- for(int a=0 ; a<arrLenght1 ; a++){
- if(array1[a]==array1[possitionCounter]){
- if(possitionCounter==arrLenght1){
- break;
- }
- digitsCounter++;
- } else if ((currentMax==0 || validation==true) && currentMax<digitsCounter){
- validation=true;
- currentMax=digitsCounter;
- digitsCounter=1;
- } else {
- digitsCounter=1;
- }
- possitionCounter++;
- }
- if(currentMax!=1){
- return currentMax;
- } else {
- return currentMax;
- }
- }
- int digit(int array1[], int arrLenght1){
- int possitionCounter=1;
- int digitsCounter=1;
- int digit=0;
- int currentMax=0;
- bool validation=false;
- for(int a=0 ; a<arrLenght1 ; a++){
- if(array1[a]==array1[possitionCounter]){
- if(possitionCounter==arrLenght1){
- break;
- }
- if(currentMax>digitsCounter){
- digitsCounter++;
- if(currentMax==digitsCounter){
- digit=array1[a];
- }
- } else {
- digit=array1[a];
- digitsCounter++;
- }
- } else if ((currentMax==0 || validation==true) && currentMax<digitsCounter){
- validation=true;
- currentMax=digitsCounter;
- digitsCounter=1;
- } else {
- digitsCounter=1;
- }
- possitionCounter++;
- }
- if(currentMax!=1){
- return digit;
- } else {
- return digit=array1[arrLenght1-1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement