Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include <stdio.h>
  2. void main(){
  3. srand (time(NULL));
  4. int sel = 0;
  5. int i = 0;
  6. char arr[23] = {'T','R','W','A','G','M','Y','F','P','D','X','B','N','J','Z','S','Q','V','H','L','C','K','E'};
  7. int num = 0;
  8. int div = 0;
  9. int j = 0;
  10. int k = 0;
  11. int l = 0;
  12. int m = 0;
  13. int n = 0;
  14. int o = 0;
  15. int p = 0;
  16. int e = 0;
  17. int y = 0;
  18. int r = 0;
  19. int w = 0;
  20. int q = 0;
  21. int t = 0;
  22. int u = 0;
  23. int prim[6];
  24. int euro[5];
  25. int can1 = 0;
  26. int can2 = 0;
  27. int ent[4];
  28. int ofic[4];
  29. int enti[4];
  30. int ofi[4];
  31. int mul1[4] = {4,8,5,10};
  32. int mul2[4] = {9,7,3,6};
  33. int num1 = 0;
  34. int num2 = 0;
  35. int res = 0;
  36. int res1 = 0;
  37. int res2 = 0;
  38. printf("Introduce el ejercicio: ");
  39. scanf("%d",&sel);
  40. switch (sel){
  41. case 1:
  42. printf("Introduce el numero del DNI: ");
  43. scanf("%d",&num);
  44. div = num % 23;
  45. printf("%d %c",num,arr[div]);
  46. break;
  47. case 2:
  48. printf("PRIMITIVA\n");
  49. for(i=0;i<6;i++){
  50. prim[i]=1+rand()%49;
  51. }
  52. for(j=0;j<6;j++){
  53. for(k=j+1;k<6;k++){
  54. if(prim[j]>prim[k]){
  55. can1=prim[j];
  56. prim[j]=prim[k];
  57. prim[k]=can1;
  58. }
  59. }
  60. }
  61. for(l=0;l<6;l++){
  62. printf(" %d",prim[l]);
  63. }
  64. printf("\n");
  65. printf("EUROMILLON\n");
  66. for(m=0;m<5;m++){
  67. euro[m]=1+rand()%50;
  68. }
  69. for(n=0;n<5-1;n++){
  70. for(o=n+1;o<5;o++){
  71. if(euro[n]>euro[o]){
  72. can2=euro[n];
  73. euro[n]=euro[o];
  74. euro[o]=can2;
  75. }
  76. }
  77. }
  78. for(p=0;p<5;p++){
  79. printf(" %d",euro[p]);
  80. }
  81. break;
  82. case 3:
  83. printf("Numero de la entitat: ");
  84. for(q=0;q<4;q++){
  85. scanf("%d", &ent[q]);
  86. }
  87. printf("Numero de la oficina: ");
  88. for(e=0;e<4;e++){
  89. scanf("%d", &ofic[e]);
  90. }
  91. for(t=0;t<4;t++){
  92. enti[t]=ent[t];
  93. ofi[t]=ofic[t];
  94. }
  95. for(w=0;w<4;w++){
  96. ent[w]=ent[w]*mul1[w];
  97. }
  98. for(r=0;r<4;r++){
  99. ofic[r]=ofic[r]*mul2[r];
  100. }
  101. for(y=0;y<4;y++){
  102. num1=num1+ent[y];
  103. num2=num2+ofic[y];
  104. }
  105. res=num1+num2;
  106. res1=res%11;
  107. res2=11-res1;
  108. for(u=0;u<4;u++){
  109. printf("%d", enti[u]);
  110. }
  111. printf(" ");
  112. for(o=0;o<4;o++){
  113. printf("%d", ofi[o]);
  114. }
  115. printf(" => %d", res2);
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement