#include <stdio.h>
#include <locale.h>
int main( void ) {
struct Aluno {
char nome[ 10 ] ;
float notaMath, notaPhysics, media;
} aluno[ 5 ] ;
for ( int contador = 0 ; contador < 5 ; contador++ ) {
printf ( "Nome do aluno %d: " , contador
+ 1 ) ; scanf ( "%s" , aluno
[ contador
] .
nome ) ; while ( 1 ) {
printf ( "Nota de matemática: " ) ; scanf ( "%f" , & aluno
[ contador
] .
notaMath ) ; if ( aluno
[ contador
] .
notaMath > 10.0 ) printf ( "Apenas notas até 10.\n " ) ; else break ;
}
while ( 1 ) {
scanf ( "%f" , & aluno
[ contador
] .
notaPhysics ) ; if ( aluno
[ contador
] .
notaPhysics > 10.0 ) printf ( "Apenas notas até 10.\n " ) ; else break ;
}
aluno[ contador] .media = ( aluno[ contador] .notaMath + aluno[ contador] .notaPhysics ) / 2 ;
}
printf ( "\n \n ------------Informações dos Alunos------------\n " ) ; for ( int contador = 0 ; contador < 5 ; contador++ ) {
printf ( "Nome do aluno %d: %s\n " , contador
+ 1 , aluno
[ contador
] .
nome ) ; printf ( "Nota de matemática: %.1f\n " , aluno
[ contador
] .
notaMath ) ; printf ( "Nota de física: %.1f\n " , aluno
[ contador
] .
notaPhysics ) ; printf ( "Média das notas: %.1f\n " , aluno
[ contador
] .
media ) ; }
}
//https://pt.stackoverflow.com/q/241369/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxsb2NhbGUuaD4KCmludCBtYWluKHZvaWQpIHsKICAgIHNldGxvY2FsZShMQ19BTEwsIlBvcnR1Z3Vlc2UiKTsKICAgIHN0cnVjdCBBbHVubyB7CiAgICAgICAgY2hhciBub21lWzEwXTsKICAgICAgICBmbG9hdCBub3RhTWF0aCwgbm90YVBoeXNpY3MsIG1lZGlhOwogICAgfSBhbHVub1s1XTsKICAgIGZvciAoaW50IGNvbnRhZG9yID0gMDsgY29udGFkb3IgPCA1OyBjb250YWRvcisrKSB7CiAgICAgICAgcHJpbnRmKCJOb21lIGRvIGFsdW5vICVkOiAiLCBjb250YWRvciArIDEpOwogICAgICAgIHNjYW5mKCIlcyIsIGFsdW5vW2NvbnRhZG9yXS5ub21lKTsKICAgICAgICB3aGlsZSAoMSkgewogICAgICAgICAgICBwcmludGYoIk5vdGEgZGUgbWF0ZW3DoXRpY2E6ICIpOwogICAgICAgICAgICBzY2FuZigiJWYiLCAmYWx1bm9bY29udGFkb3JdLm5vdGFNYXRoKTsKICAgICAgICAgICAgaWYgKGFsdW5vW2NvbnRhZG9yXS5ub3RhTWF0aCA+IDEwLjApIHByaW50ZigiQXBlbmFzIG5vdGFzIGF0w6kgMTAuXG4iKTsKICAgICAgICAgICAgZWxzZSBicmVhazsKICAgICAgICB9CiAgICAgICAgd2hpbGUgKDEpIHsKICAgICAgICAgICAgcHJpbnRmKCJOb3RhIGRlIGbDrXNpY2E6ICIpOwogICAgICAgICAgICBzY2FuZigiJWYiLCAmYWx1bm9bY29udGFkb3JdLm5vdGFQaHlzaWNzKTsKICAgICAgICAgICAgaWYgKGFsdW5vW2NvbnRhZG9yXS5ub3RhUGh5c2ljcyA+IDEwLjApIHByaW50ZigiQXBlbmFzIG5vdGFzIGF0w6kgMTAuXG4iKTsKICAgICAgICAgICAgZWxzZSBicmVhazsKICAgICAgICB9CiAgICAgICAgYWx1bm9bY29udGFkb3JdLm1lZGlhID0gKGFsdW5vW2NvbnRhZG9yXS5ub3RhTWF0aCArIGFsdW5vW2NvbnRhZG9yXS5ub3RhUGh5c2ljcykgLyAyOwogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KICAgIHByaW50ZigiXG5cbi0tLS0tLS0tLS0tLUluZm9ybWHDp8O1ZXMgZG9zIEFsdW5vcy0tLS0tLS0tLS0tLVxuIik7CiAgICBmb3IgKGludCBjb250YWRvciA9IDA7IGNvbnRhZG9yIDwgNTsgY29udGFkb3IrKykgewogICAgICAgIHByaW50ZigiTm9tZSBkbyBhbHVubyAlZDogJXNcbiIsIGNvbnRhZG9yKzEsIGFsdW5vW2NvbnR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