Skip to content

Instantly share code, notes, and snippets.

@so77id
Last active July 5, 2021 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save so77id/474e0a82aee316ab8a20aa809a346fb1 to your computer and use it in GitHub Desktop.
Save so77id/474e0a82aee316ab8a20aa809a346fb1 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
/*
* Complete the 'ranking3' function below.
*
* The function accepts INTEGER_ARRAY roulette as parameter.
*/
const int SIZE = 37;
void sort(int arr[], int indices[], int size) {
for(int k = size; k >= 0; k-- ){
for(int i = 0; i < k-1; i++) {
if(arr[i] < arr[i+1] && indices[i] < indices[i+1]) {
//swap
int aux = arr[i];
arr[i] = arr[i+1];
arr[i+1] = aux;
aux = indices[i];
indices[i] = indices[i+1];
indices[i+1] = aux;
}
}
}
}
void ranking3(int roulette[]) {
int indices[SIZE];
for(int i = 0; i<SIZE;i++) {
indices[i]=i;
}
sort(roulette, indices, SIZE);
for(int i = 0; i < 3; i++) {
cout << indices[i] << endl;
}
}
int main()
{
int roulette[SIZE];
for(int i = 0; i < SIZE; i++) {
cin >> roulette[i];
}
ranking3(roulette);
return 0;
}
#include<iostream>
using namespace std;
const int SIZE = 37;
void notAppear(int roulette[]) {
for(int i = 0; i < SIZE; i++) {
if(roulette[i] == 0) {
cout << i << endl;
}
}
}
int main() {
int roulette[SIZE];
for(int i = 0; i < SIZE; i++) {
cin >> roulette[i];
}
notAppear(roulette);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment