Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int pljuniId(int* nums, int cnt) {
- int i;
- int max = nums[0] % 10, maxId = 0; //pretpostavljamo
- int cif;
- for ( i = 0; i < cnt; i ++ ) { //idemo broj po broj.
- while ( nums[i] != 0 ) { //idemo cifru po cifru.
- cif = nums[i] % 10;
- if ( cif > max ) {
- max = cif;
- maxId = i;
- }
- else if ( cif == max ) {
- while ( (nums[maxId] % 10) == (nums[i] % 10) ) {
- nums[maxId] /= 10;
- nums[i] /= 10;
- if ( nums[i] == 0 ) break;
- }
- }
- nums[i] /= 10;
- }
- }
- return maxId;
- }
- int main()
- {
- int nums[10] = {123, 321, 12, 325, 125, 57, 5125, 1252, 12521, 12552};
- printf("%d", pljuniId(nums, 10));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment