Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1
- //a) Vai dar erro por nao criar a variavel j
- //9%3 == 0 | x = 9
- //8%3 == 2 | j = 8
- //7%3 == 1 | x = 9
- // i = 1
- //7%3 == 1 | x = 7
- //i = 2
- //b) erro, a e b nao criado
- //b = 4
- //b = 6
- //b = 7
- //b = 9
- //a = 4
- //b = 6
- //b = 7
- //b = 9
- //a = 6
- //b = 8
- //a = 8
- //c)
- //x = 24 | y = 4
- //2
- int Multiplos(int n, int m)
- {
- printf("%d múltiplos de %d:\n",n,m);
- for(int i=0; i<n; i++)
- printf("[%d]",m*i);
- }
- //3
- int Traco(int *mat, int elem)
- {
- int soma=0;
- for(int i=0; i<elem; i++)
- soma+=*(mat+(i+i*elem));
- return soma;
- }
- //4
- //a)
- typedef struct
- {
- char nome[60];
- int nota;
- int numerofaltas;
- }ALUNO;
- ALUNO turma[30];
- //b)
- int InicTurma()
- {
- int n;
- printf("Insira o numero de alunos (máximo 30): ");
- while(scanf("%d", &n) != 1 || n > 30 || n < 0)
- printf("Insira o numero de alunos (máximo 30): ");
- for(int i=0; i<n; i++)
- {
- printf("\nNome: ");
- scanf("%s", turma[i].nome);
- printf("\nNota: ");
- scanf("%d", &turma[i].nota);
- printf("\nNumero de Faltas: ");
- scanf("%d", &turma[i].numerofaltas);
- }
- return n;
- }
- //c)
- int Aprovados(int n)
- {
- int ap=0;
- printf("Alunos aprovados:\n");
- for(int i=0; i<n; i++)
- if(turma[i].nota > 9.5 && turma[i].numerofaltas < 4)
- {
- printf("%s\n", turma[i].nome);
- ap++;
- }
- return ap;
- }
- //5
- float LaSoma(int N)
- {
- if(N == 1)
- return 1/3;
- return LaSoma(N-1)+1/(3*N);
- }
- //6
- int TamFile(char *nome)
- {
- int size;
- FILE *f = fopen(nome, "rb");
- if(!f) return 0;
- fseek(f, 0, SEEK_END);
- size = ftell(f);
- fclose(f);
- return size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement