Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int n, cont = 1;
- bool read() {
- scanf("%d", &n);
- return n != 0;
- }
- void process() {
- int pos[n];
- char nome[n][16];
- int pts[13][n];
- int max;
- int min;
- int total[n];
- for (int i = 0; i < n; i++) {
- max = -1;
- min = 1001;
- scanf("%s", &nome[i]);
- total[i] = 0;
- for (int j = 0; j < 12; j++) {
- scanf("%d", &pts[j][i]);
- if (pts[j][i] > max)
- max = pts[j][i];
- if (pts[j][i] < min)
- min = pts[j][i];
- total[i] += pts[j][i];
- }
- //total[i] = pts[0][i]+pts[1][i]+pts[2][i]+pts[3][i]+pts[4][i]+pts[5][i]+pts[6][i]+pts[7][i]+pts[8][i]+pts[9][i]+pts[10][i]+pts[11][i];
- total[i] -= max;
- total[i] -= min;
- for (int k = 0; k < i; k++) {
- if (strcmp(nome[i], nome[k]) < 0) {
- int aux = total[i];
- total[i] = total[k];
- total[k] = aux;
- char temp[16]; strcpy(temp, nome[i]);
- strcpy(nome[i], nome[k]);
- strcpy(nome[k], temp);
- //lol = true;
- }
- if (total[i] > total[k]) {
- int aux = total[i];
- total[i] = total[k];
- total[k] = aux;
- char temp[16]; strcpy(temp, nome[i]);
- strcpy(nome[i], nome[k]);
- strcpy(nome[k], temp);
- }
- }
- }
- printf("Teste %d", cont);
- for (int i = 0; i < n; i++) {
- pos[0] = 1;
- if (total[i] == total[i-1]) {
- pos[i] = pos[i-1];
- }
- else
- pos[i] = i+1;
- printf("\n%d %d %s", pos[i], total[i], nome[i]);
- }
- }
- int main() {
- while(read()) {
- process();
- cont++;
- printf("\n\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement