-
-
Save Abreto/3487389 to your computer and use it in GitHub Desktop.
RQNOJ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* RQNOJ Problem 1. 明明的随机数. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
int i = 0, m = 0; | |
int N = 0, *data = NULL; | |
int *arr = NULL, max = 0, count = 0; | |
// 输入数据 | |
scanf("%d\n", &N); | |
data = (int *)malloc( N * sizeof(int) ); | |
for(i = 0;i < N;i++) | |
{ | |
scanf("%d", data + i); | |
if( *(data+i) > max ) | |
max = *(data+i); | |
} | |
// 排序 | |
max++; | |
arr = (int *)malloc( max * sizeof(int) ); | |
for(i = 0;i < max;i++) *(arr+i) = 0; | |
for(i = 0;i < N;i++) | |
*( arr + *(data+i) ) = *(data+i); | |
for(i = 0;i < max;i++) | |
if( *(arr+i) != 0 ) | |
*(data+m++) = *(arr+i); | |
// 输出 | |
printf("%d\n", m); | |
for(i = 0;i < m-1;i++) | |
printf("%d ", *(data+i)); | |
printf("%d", *(data+i)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* RQNOJ Problem 16. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define YS 8000 | |
#define WS 4000 | |
#define CJ 2000 | |
#define XB 1000 | |
#define BJ 850 | |
typedef struct _student | |
{ | |
char name[20]; | |
int score; | |
int class; | |
char is_jb; | |
char is_west; | |
int thesis; | |
int money; | |
}student; | |
int calculate_money(student* s); | |
int main(void) | |
{ | |
int i = 0; | |
int N = 0; | |
student *stu = NULL, max = {' ', 0, 0, 0, 0, 0, 0}; | |
char is_jb, is_west; | |
int total = 0; | |
// input | |
scanf("%d", &N); | |
stu = (student *)malloc( N * sizeof(student) ); | |
for(i = 0;i < N;i++) | |
{ | |
scanf("%s %d %d %c %c %d", (stu+i)->name, &((stu+i)->score), &((stu+i)->class), &is_jb, &is_west, &((stu+i)->thesis)); | |
(stu+i)->is_jb = is_jb == 'Y' ? 1 : 0; | |
(stu+i)->is_west = is_west == 'Y' ? 1 : 0; | |
} | |
for(i = 0;i < N;i++) | |
{ | |
if( calculate_money(stu+i) > max.money ) | |
max = *(stu+i); | |
total += (stu+i)->money; | |
} | |
// output | |
printf("%s\n%d\n%d\n", max.name, max.money, total); | |
return 0; | |
} | |
int calculate_money(student *s) | |
{ | |
s->money = 0; | |
// 1 YS | |
if( ( s->score > 80 ) && ( s->thesis > 0 ) ) | |
s->money += YS; | |
// 2 WS | |
if( ( s->score > 85 ) && ( s->class > 80 ) ) | |
s->money += WS; | |
// 3 CJ | |
if( s->score > 90 ) | |
s->money += CJ; | |
// 4 XB | |
if( ( s->score > 85 ) && ( s->is_west ) ) | |
s->money += XB; | |
// 5 BJ | |
if( ( s->class > 80 ) && ( s->is_jb ) ) | |
s->money += BJ; | |
// result | |
return (s->money); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment