Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Essa estrutura deve ter o nome da banda, que tipo de música ela toca,
- o número de integrantes e em que posição do ranking essa banda está
- dentre as suas 5 bandas favoritas.*/
- #include <stdio.h>
- #define MAX 100
- #define NUM 2
- struct banda{
- char nome_da_banda[MAX], tipo_de_musica[MAX];
- int num_de_integrantes, posicao;
- }ranking[NUM];
- void preenche(struct banda *pnt){
- for(int i=0; i<NUM; i++){
- printf("Nome da banda: ");
- scanf(" %[^\n]", pnt->nome_da_banda[i]);
- printf("Tipo de musica: ");
- scanf(" %[^\n]", pnt->tipo_de_musica[i]);
- printf("Numero de integrantes: ");
- scanf("%d", &pnt->num_de_integrantes[i]);
- printf("Posicao do ranking de suas 5 bandas preferidas (digite um numero de 1 a 5): ");
- scanf("%d", &pnt->posicao[i]);
- printf("\n");
- }
- }
- void imprime(struct banda *pnt){
- for(int i=0; i<NUM; i++){
- printf("\n%s", pnt[i].nome_da_banda);
- printf("\n%s", pnt[i].tipo_de_musica);
- printf("\n%d", pnt[i].num_de_integrantes);
- printf("\n%d", pnt[i].posicao);
- }
- }
- int main(){
- struct banda ranking;
- struct banda *pnt;
- preenche(&ranking);
- imprime(&ranking);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment