Ejemplo n.º 1
0
int main(void)
{
	double min=0.0, lower=0.0;
	freopen("cowtour.in",  "r",  stdin);
	freopen("cowtour.out",  "w",  stdout);

	scanf("%d", &lim);
	for(int i=0; i<lim; i++)
		scanf("%d%d\n", &pos[i].x, &pos[i].y);
	for(int i=0; i<lim; i++){
		char c;
		for(int j=0; j<lim; j++){
			scanf("%c", &c);
			if(c == '1'){
				int tx=pos[i].x-pos[j].x;
				int ty=pos[i].y-pos[j].y;
				dis[i][j] = dis[j][i] = sqrt(tx*tx+ty*ty);
			}else
				dis[i][j] = dis[j][i] = 0.0;
		}
		scanf("%c", &c);
	}
	floyd();
	for(int i=0; i<lim; i++){
		max[i] = dis[i][0];
		for(int j=1; j<lim; j++){
			if(i!=j && great(dis[i][j], max[i]))
				max[i] = dis[i][j];
		}
		if(equal(lower, 0.0) || great(max[i], lower))
			lower = max[i];
	}
	for(int i=0; i<lim; i++){
		for(int j=i+1; j<lim; j++){
			if(equal(dis[i][j], 0.0)){
				int tx=pos[i].x-pos[j].x;
				int ty=pos[i].y-pos[j].y;
				double d=sqrt(tx*tx+ty*ty)+max[i]+max[j];
				if(equal(min, 0.0) || little(d, min))
					min = d;
			}
		}
	}
	if(little(min, lower))
		min = lower;
	printf("%.6lf\n", min);
	return 0;
}
Ejemplo n.º 2
0
int main ()
{
	struct Student *head,*p;
	head=great();
	p=head;
    for (;p!=NULL;p=p->next)
		printf ("%3d %6s %3.1f %3.1f %3.1f\n", (*p).num,(*p).name,(*p).gread[0],(*p).gread[1],(*p).gread[2]);
	return 0;
}
Ejemplo n.º 3
0
char *expression(void){
	char *var1, *var2;
	var1 = great();
	while(match(EQUALS)){
		comp_count++;
		advance();
		var2 = great();
		//printf("%s = %s == %s\n", var1, var2);
		fprintf(f, "CMP %s, %s\n", var1,var2);
		fprintf(f, "JE CMP0%d\n", comp_count, comp_count);
		fprintf(f, "MOVB $0, %s\n",var1 );
		fprintf(f, "JMP CMP1%d\n", comp_count);
		fprintf(f, "CMP0%d:\nMOVB $1, %s\n", comp_count, var1 );
		fprintf(f, "CMP1%d:\n", comp_count);
		freename(var2);
	}

	return var1;
}
Ejemplo n.º 4
0
int main()
{
	void input(struct Student stu[]);
	void order(struct Student stu[]);
	void great(struct Student stu[]); 
	struct Student stu[N],*p=stu;
	input(p);
	order(p);
	great(p);
	return 0;
}
Ejemplo n.º 5
0
int main()
{
int store[10], i;
for(i=0; i<10; i++)
store[i] = rand()%101;

great(store);

return 0; 

}
Ejemplo n.º 6
0
void draw_plot(void *obj, void *data)
{
	function_t *func = (function_t *)obj;
	bundled_info_t *bi = (bundled_info_t *)data;

	plot_info_t info = bi->info;
	window_info_t *winfo = bi->winfo;
	SDL_Surface *screen = bi->screen;

	color_t plot = func->plot_col;

	double orig_y_scale = ((winfo->max - winfo->min) / winfo->height);

	int i;
	for(i = 0; i < winfo->width; i++)
	{
		double x_val = i * info.x_scale - info.x_axis * info.x_scale;
		if(func->bounded)
		{
			if(x_val < func->bound_left || x_val > func->bound_right)
				continue;
		}

		if(!func->show_nan && (func->vals[i] != func->vals[i] || (i < winfo->width - 1 && func->vals[i + 1] != func->vals[i + 1])))
			continue;

		int ypt = winfo->height - (func->vals[i] / info.y_scale) - (info.offset / orig_y_scale);

		int ht = 1;

		if(!func->discreet)
		{
			int npt = (i < winfo->width - 1 ? winfo->height - ((func->vals[i + 1] / info.y_scale)) - (info.offset / orig_y_scale): ypt);
			ht = abs(great(ypt, npt) - less(npt, ypt));
			ht = ht == 0 ? 1 : ht;

			if(ht > winfo->height)
				continue;

			ypt = less(npt, ypt);
		}

		if(func->shade)
			shadeWith(ypt, i, info.y_axis, screen, func->shade_col);

		SDL_Rect dest = {i, ypt, 1, ht};
		SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, plot.r, plot.g, plot.b));
	}
}
Ejemplo n.º 7
0
int main(){
	int i = 0, j = 0;
	int *pnum, num[M]; //num存放每位学生的学号
	
	float score[M][N], *pscore;
	float aver[M], *paver; //aver存放每位学生的平均分
	
	char course[N][40], *pcourse; //course存放5门课程的名称

	printf("请按行输入5门功课的名称:\n");
	pcourse = course[i];
	for(i=0; i<N; ++i){
		scanf("%s", pcourse+40*i);
	}		

	printf("请按照下面的格式输入4个学生的学号和各科成绩:(以空格间隔)\n");
	printf("学号");
	for(i=0; i<N; ++i){
		printf(" %s", pcourse+40*i);
	}
	printf("\n");

	pscore = &score[0][0];
	pnum = &num[0];
	for(i=0; i<M; ++i){
		scanf("%d", pnum+i);
		for(j=0; j<N; ++j){
			scanf("%f", pscore+N*i+j);
		}
	}

	paver = &aver[0];
	printf("\n\n");
	averscore(pscore, paver); 
	avercour5(pcourse, pscore);
	printf("\n\n");
	fail2(pcourse, pnum, pscore, paver);
	printf("\n\n");
	great(pcourse, pnum, pscore, paver);
	return 0;
}
Ejemplo n.º 8
0
void draw_crosshair(void *obj, void *data)
{
	function_t *func = (function_t *)obj;
	bundled_info_t *bit = (bundled_info_t *)data;
	window_info_t *winfo = bit->winfo;
	int loc = bit->x;
	SDL_Surface *screen = bit->screen;
	plot_info_t info = bit->info;

	double orig_y_scale = ((winfo->max - winfo->min) / winfo->height);
	color_t hair_col = winfo->hair_col;

	if(!func->show_hair)
		return;

	if(func->vals[loc] != func->vals[loc] || (func->discreet && loc < winfo->width - 1 && func->vals[loc + 1] != func->vals[loc + 1]))
		return;

	int ypt = winfo->height - (func->vals[loc] / info.y_scale) - (info.offset / orig_y_scale);
	int ht = 1;

	if(!func->discreet)
	{
		int npt = (loc < winfo->width - 1 ? winfo->height - ((func->vals[loc + 1] / info.y_scale)) - (info.offset / orig_y_scale): ypt);
		ht = abs(great(ypt, npt) - less(npt, ypt));
		ht = ht == 0 ? 1 : ht;

		ypt = (npt + ypt) / 2;
	}

	SDL_Rect top = {loc, ypt - 4, 1, 4};
	SDL_Rect right = {loc + 1, ypt, 4, 1};
	SDL_Rect bottom = {loc, ypt + 1, 1, 4};
	SDL_Rect left = {loc - 4, ypt, 4, 1};

	SDL_FillRect(screen, &top, SDL_MapRGB(screen->format, hair_col.r, hair_col.g, hair_col.b));
	SDL_FillRect(screen, &right, SDL_MapRGB(screen->format, hair_col.r, hair_col.g, hair_col.b));
	SDL_FillRect(screen, &bottom, SDL_MapRGB(screen->format, hair_col.r, hair_col.g, hair_col.b));
	SDL_FillRect(screen, &left, SDL_MapRGB(screen->format, hair_col.r, hair_col.g, hair_col.b));
}
Ejemplo n.º 9
0
int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){
	int currentPlayer = whoseTurn(state);
	
	//uses switch to select card and perform actions
	switch( card ){
		case adventurer:
			adv(currentPlayer, state);
			break;
		case council_room:
			council(currentPlayer, state, handPos);
			break;
		case feast:
			fea(currentPlayer, state, choice1);
			break;
		case gardens:
			return -1;
		case mine:
			min(currentPlayer, state, handPos, choice1, choice2);
			break;
		case remodel:
			rem(currentPlayer, state, handPos, choice1, choice2);
			break;
		case smithy:
			smi(currentPlayer, state, handPos);
			break;
		case village:
			vill(currentPlayer, state, handPos);
			break;
		case baron:
			bar(currentPlayer, state, choice1);
			break;
		case great_hall:
			great(currentPlayer, state, handPos);
			break;
		case minion:
			mini(currentPlayer, state, handPos, choice1, choice2);
			break;
		case steward:
			stew(currentPlayer, state, handPos, choice1, choice2, choice3);
			break;
		case tribute:
			trib(currentPlayer, state);
			break;
		case ambassador:
			ambass(currentPlayer, state, handPos, choice1, choice2);
			break;
		case cutpurse:
			catp(currentPlayer, state, handPos);
			break;
		case embargo: 
			embar(currentPlayer, state, handPos, choice1);
			break;
		case outpost:
			outp(currentPlayer, state, handPos);
			break;
		case salvager:
			salv(currentPlayer, state, handPos, choice1);
			break;
		case sea_hag:
			seahag(currentPlayer, state);
			break;
		case treasure_map:
			treasur(currentPlayer, state, handPos);
			break;
	}
	
  return -1;
}