Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- int idAluno[10] = {0};
- float notaAluno[10] = {0};
- // Entering the id data
- for (int i=0; i<10; i++) {
- printf("Digite o ID do aluno %d: ", i);
- scanf("%d", &idAluno[i]);
- }
- // Entering average
- for (int i=0; i<10; ++i) {
- printf("A nota do aluno %d: ", i);
- scanf("%f", ¬aAluno[i]);
- }
- // Ordenation algorithm
- for (int i=0; i<10; i++) {
- for (int j=0; j<10-i; j++) {
- if (notaAluno[i] > notaAluno[j]) {
- float swp_average = notaAluno[i];
- int swp_id = idAluno[i];
- notaAluno[i] = notaAluno[j];
- notaAluno[j] = swp_average;
- idAluno[i] = idAluno[j];
- idAluno[j] = swp_id;
- }
- }
- }
- // Listing the id
- for (int i=0; i<10; ++i) {
- printf("ID do aluno %d: %d\n", i, idAluno[i]);
- }
- // Listing the average
- for (int i=0; i<10; ++i) {
- printf("A nota do aluno %d: %.2f\n", i, notaAluno[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement