Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
20171117_FUNCIONES
#include <stdio.h> #include <stdlib.h> unsigned long long factorial(unsigned short a); unsigned short mcd(unsigned short a, unsigned short b); short digitoDenN(unsigned long long n, unsigned short d); short digitosRepetidos(unsigned long long n); int main() { unsigned short n; unsigned long long f; printf("Valor de n... "); scanf(" %hu", &n); f = factorial(n); printf("El factorial de %hu es %llu\n", n, f); unsigned short a, b, c; printf("Valor de a... "); scanf(" %hu", &a); printf("Valor de b... "); scanf(" %hu", &b); c = mcd(a, b); printf("El mcd de %hu y %hu es %hu\n", a, b, c); unsigned long long N; unsigned short digito; printf("Valor de N... "); scanf(" %llu", &N); do{ printf("Digito... "); scanf(" %hu", &digito); }while(digito > 9); if(digitoDenN(N, digito)) { printf("El digito %hu SI esta en %llu\n", digito, N); } else { printf("El digito %hu NO esta en %llu\n", digito, N); } if(digitosRepetidos(N)) { printf("%llu SI tiene digitos repetidos\n", N); } else { printf("%llu NO tiene digitos repetidos\n", N); } return 0; } unsigned long long factorial(unsigned short a) { unsigned long long f = 1; while(a) f *= a--; return f; } unsigned short mcd(unsigned short a, unsigned short b) { short aux; while(b) { aux = a; a = b; b = aux % b; } return a; } short digitoDenN(unsigned long long n, unsigned short d) { while(n) { if(n % 10 == d) return 1; n /= 10; } return 0; } short digitosRepetidosNOVATO(unsigned long long n) { unsigned short d; unsigned long long restoNumero; while(n) { d = n % 10; restoNumero = n / 10; while(restoNumero) { if(restoNumero % 10 == d) { return 1; } restoNumero /= 10; } n /= 10; } return 0; } short digitosRepetidos(unsigned long long n) { while(n) { if(digitoDenN(n / 10, n % 10)) { return 1; } n /= 10; } return 0; }
run
|
edit
|
history
|
help
0
My first program
blue point
Project 3 Part 1 v1.75
150113_CribaErastotenes
Critical Openmp Example
PJE
assignment 3 celina
Spring 2017 Project 2 v1.2
Greeting
time clock and day count through second by user input (ratneshgujarathi)