Created
September 28, 2017 06:40
-
-
Save unaipme/fcf2a4f1cf9d4e734263982ebc848338 to your computer and use it in GitHub Desktop.
Digitu bat zenbaki baten zein posiziotan agertzen den aurkitzen duen kodea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
int n, digitua, posizioa; | |
int aurkituta = 0; // aparte jarri det boolean bezela erabiliko dugulako | |
printf("Idatzi zenbakia: "); | |
scanf("%d", &n); | |
printf("Bilatzeko digitua: "); | |
scanf("%d", &digitua); | |
while (n >= 1 && !aurkituta) { | |
posizioa++; | |
if (n % 10 == digitua) { | |
aurkituta = 1; | |
} | |
n = n / 10; // n /= 10; | |
} | |
if (aurkituta) { | |
printf("Digitua %d posizioan aurkitu dut.\n", posizioa); | |
} else { | |
printf("Ez dut digitua aurkitu.\n"); | |
} | |
getchar(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment