3
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef struct{
int id;
char nome[20];
tipoTelefone telefone;
}tipoCliente;
typedef struct{
int x1;
int x2;
int x3;
int x4;
char digito;
int y1;
int y2;
int y3;
int y4;
}tipoTelefone;
int main(){
int n,q,i,j,cont;
char teste;
printf("Qtds:\n");
scanf("%d %d",&n,&q);
tipoCliente cliente[n];
for(i = 0; i < n; i++){
scanf("%d %s %d%d%d%d%s%d%d%d%d",&cliente[i].id,&cliente[i].nome,&cliente[i].telefone.x1,&cliente[i].telefone.x2,&cliente[i].telefone.x3,&cliente[i].telefone.x4,&cliente[i].telefone.digito,&cliente[i].telefone.y1,&cliente[i].telefone.y2,&cliente[i].telefone.y3,&cliente[i].telefone.y4);
}
// for(j = 0; j < q; j++){
// scanf("%d",&q_id);
// }
//
// for(i = 0; i < n - 1; i++){
// if(strcmp(cliente[i].nome,cliente[i + 1].nome) < 0){
//
// }else if(strcmp(cliente[i].nome,cliente[i + 1].nome) == 0){
// if(cliente[i].id > cliente[i + 1].id){
//
// }
// }
// }
printf("\n");
for(i = 0; i < n; i++){
printf("%d %s %d%d%d%d%s%d%d%d%d",cliente[i].id,cliente[i].nome,cliente[i].telefone.x1,cliente[i].telefone.x2,cliente[i].telefone.x3,cliente[i].telefone.x4,cliente[i].telefone.digito,cliente[i].telefone.y1,cliente[i].telefone.y2,cliente[i].telefone.y3,cliente[i].telefone.y4);
}
return 0;
}
I did it because I can’t think of a way to receive a phone number in the format xxxx-yyyy and with that phone number, make the following sum: xxxx+yyyy. If you have a tip, I’d appreciate it. Anyway, I appreciate the help.
– Vinicius Vasconcelos
I can’t imagine why I would make this sum. https://answall.com/q/47871/101.
– Maniero
To suit the criteria of a program I am doing. The criterion is that for each client, the sum xxxx + yyyy is calculated. Then, the rest of this sum is calculated in the division by 7, that is, the result value is a number between 0 and 6. The client that has the lowest value must be called first
– Vinicius Vasconcelos
Wow, that’s a crazy requirement, but anyway there are better ways to build this, but that’s another subject that I don’t even want.
– Maniero
College stuff, man. Anyway, you’ve helped a lot with the struct error. Thanks!
– Vinicius Vasconcelos
at least change the type
int
forchar
to save space.– Maniero