Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int Obrni (int n) {
- int nb=0, k=0;
- while (n!=0) {
- nb=nb*10+n%10;
- n/=10;
- }
- return nb;
- }
- int DrugaCifra (int n) {
- int broj=Obrni(n);
- int cifra=0, i=0;
- while (broj!=0) {
- cifra=broj%10;
- i++;
- broj/=10;
- if (i==2 && cifra==5) return 1;
- }
- return 0;
- }
- int Suma (int*niz, int vel) {
- int i;
- int suma=0;
- for (i=0; i<vel; i++) {
- if (DrugaCifra(niz[i])) suma+=niz[i];
- }
- return suma;
- }
- int main () {
- int niz[6]={25, 53, 5, 185, 357, 2501};
- printf("%d", Suma(niz,6));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement