Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. void funcion(int numero,int dimension,char l[100]){
  5. int c[100];
  6. int i;
  7. int x,seguir = 0;
  8. while(seguir == 0){
  9. for(i = 1;i<dimension;i++){
  10. c[i] = numero%(int)pow(10,i);
  11. }
  12. if(c[i]<= 1){
  13. seguir = 1;
  14. }
  15. }
  16. for(i = 1; i<dimension;i++){
  17. x = c[i];
  18. if(x == 0){
  19. l[i] = '-----';
  20. }
  21. if(x == 1){
  22. l[i] = '.----';
  23. }
  24. if(x == 2){
  25. l[i] = '..---';
  26. }
  27. if(x == 3){
  28. l[i] = '...--';
  29. }
  30. if(x == 4){
  31. l[i] = '....-';
  32. }
  33. if(x == 5){
  34. l[i] = '.....';
  35. }
  36. if(x == 6){
  37. l[i] = '-....';
  38. }
  39. if(x == 7){
  40. l[i] = '--...';
  41. }
  42. if(x == 8){
  43. l[i] = '---..';
  44. }
  45. if(x == 9){
  46. l[i] = '----.';
  47. }
  48.  
  49. }
  50.  
  51.  
  52. }
  53. int main(){
  54. char l[100];
  55. int numero,dimension,i,c;
  56. printf("Introduce la dimension");
  57. scanf("%d",&dimension);
  58. printf("Introduce el nummero");
  59. scanf("%d",&numero);
  60. printf("El numero es %d",numero);
  61. funcion(numero,dimension,&l[100]);
  62. printf("El codigo morse es \n");
  63. for(i = dimension;i<1;i--){
  64. printf("%c ",l[i]);
  65. }
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement