Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main(){
- srand (time(NULL));
- int sel = 0;
- int i = 0;
- 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'};
- int num = 0;
- int div = 0;
- int j = 0;
- int k = 0;
- int l = 0;
- int m = 0;
- int n = 0;
- int o = 0;
- int p = 0;
- int e = 0;
- int y = 0;
- int r = 0;
- int w = 0;
- int q = 0;
- int t = 0;
- int u = 0;
- int prim[6];
- int euro[5];
- int can1 = 0;
- int can2 = 0;
- int ent[4];
- int ofic[4];
- int enti[4];
- int ofi[4];
- int mul1[4] = {4,8,5,10};
- int mul2[4] = {9,7,3,6};
- int num1 = 0;
- int num2 = 0;
- int res = 0;
- int res1 = 0;
- int res2 = 0;
- printf("Introduce el ejercicio: ");
- scanf("%d",&sel);
- switch (sel){
- case 1:
- printf("Introduce el numero del DNI: ");
- scanf("%d",&num);
- div = num % 23;
- printf("%d %c",num,arr[div]);
- break;
- case 2:
- printf("PRIMITIVA\n");
- for(i=0;i<6;i++){
- prim[i]=1+rand()%49;
- }
- for(j=0;j<6;j++){
- for(k=j+1;k<6;k++){
- if(prim[j]>prim[k]){
- can1=prim[j];
- prim[j]=prim[k];
- prim[k]=can1;
- }
- }
- }
- for(l=0;l<6;l++){
- printf(" %d",prim[l]);
- }
- printf("\n");
- printf("EUROMILLON\n");
- for(m=0;m<5;m++){
- euro[m]=1+rand()%50;
- }
- for(n=0;n<5-1;n++){
- for(o=n+1;o<5;o++){
- if(euro[n]>euro[o]){
- can2=euro[n];
- euro[n]=euro[o];
- euro[o]=can2;
- }
- }
- }
- for(p=0;p<5;p++){
- printf(" %d",euro[p]);
- }
- break;
- case 3:
- printf("Numero de la entitat: ");
- for(q=0;q<4;q++){
- scanf("%d", &ent[q]);
- }
- printf("Numero de la oficina: ");
- for(e=0;e<4;e++){
- scanf("%d", &ofic[e]);
- }
- for(t=0;t<4;t++){
- enti[t]=ent[t];
- ofi[t]=ofic[t];
- }
- for(w=0;w<4;w++){
- ent[w]=ent[w]*mul1[w];
- }
- for(r=0;r<4;r++){
- ofic[r]=ofic[r]*mul2[r];
- }
- for(y=0;y<4;y++){
- num1=num1+ent[y];
- num2=num2+ofic[y];
- }
- res=num1+num2;
- res1=res%11;
- res2=11-res1;
- for(u=0;u<4;u++){
- printf("%d", enti[u]);
- }
- printf(" ");
- for(o=0;o<4;o++){
- printf("%d", ofi[o]);
- }
- printf(" => %d", res2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement