예제 #1
0
void main()
{
    char s1[20],s2[20];
    gets(s1);
    gets(s2);
    check_rotation(s1,s2);
}
예제 #2
0
int main()
{
	char str1[100];
	scanf("%s",str1);
	char str2[100];
	scanf("%s",str2);
	if(check_rotation(str1, str2))
		printf("String are rotations of each other.\n");
	else
		printf("String are not rotations of each other.\n");
	return 0;
}
예제 #3
0
// メイン関数
int main( int argc, char *argv[] )
{
	FILE	*fp = NULL;
	char	*s;
	int		i;
	int		file_open	= 0;	// ファイルオープン確認フラグ

	// option解析
	for(i = 1; i < argc; i++){
		if(argv[i][0] == '-'){
			if(argv[i][1] == 't')
				g_thread = strtol(argv[i] + 2, &s, 10);
			else if(argv[i][1] == 'r')
				g_auto_repair = 1;
			else if(argv[i][1] == 'l')
				g_rotation = strtol(argv[i] + 2, &s, 10) + 1;
			else if(argv[i][1] == 'd')
				g_debug_mode = 1;
			else if(argv[i][1] == 'h'){
				switch(argv[i][2]) {
				case 'c':
					g_console = CONSOLE_COLORGAMEBOY; break;
				case 'g':
					g_console = CONSOLE_GAMEBOY; break;
				case 'n':
					g_console = CONSOLE_NEOGEOPOCKETCOLOR; break;
				case 'w':
					g_console = CONSOLE_SWANCRYSTAL; break;
				case 'p':
					g_console = CONSOLE_PIECE; break;
				case 's':
					g_console = CONSOLE_GAMEGEAR; break;
				default:
					printf("パラメータがおかしい = %c\n", argv[i][2]);
					show_opt(fp, argv[0]);
					break;
				}
			}
			else if(argv[i][1] == 'v')
				show_opt(fp, argv[0]);
			else {
				printf("パラメータがおかしい = %s\n", argv[i]);
				show_opt(fp, argv[0]);
			}
		}
		else if(file_open == 0){
			fp = fopen( argv[i], "rb");    /* ファイルオープン(読み込みモード) */
			if(fp == NULL){        /* オープン失敗 */
				printf("ファイルがオープンできません\n");
				exit(-1);
			}
			else file_open = 1;
		}
	}

	if (fp == NULL) show_opt(fp, argv[0]);

	// 変数への初期設定
	if (g_console == 0) show_opt(fp, argv[0]);	// ハード選択必須
	g_thread	= check_thread(g_thread);
	g_rotation	= check_rotation(g_rotation);
	set_xy(g_rotation);

	// 情報出力
	show_outputdata(g_thread, g_rotation);

	// メイン処理
	rawtopng(fp);

	// ファイルクローズ
	fclose(fp);

	return 0;
}
예제 #4
0
/******************************************************************************\
 Calculates a new camera rotation matrix and reloads the modelview matrix.
\******************************************************************************/
void R_update_camera(void)
{
        c_vec3_t x_axis, y_axis, z_axis, diff;

        R_push_mode(R_MODE_3D);
        glMatrixMode(GL_MODELVIEW);

        /* Update zoom */
        r_cam_zoom += cam_zoom_diff;
        if (r_cam_zoom > r_zoom_max)
                r_cam_zoom = r_zoom_max;
        if (r_cam_zoom < R_ZOOM_MIN)
                r_cam_zoom = R_ZOOM_MIN;
        cam_zoom_diff = 0.f;

        /* Momentum mode changes the meaning of the camera difference vector
           to velocity rather than change-per-frame */
        diff = cam_rot_diff;
        if (cam_momentum) {
                float prop;

                diff = C_vec3_scalef(diff, c_frame_sec);
                prop = 1.f - c_frame_sec * CAM_FRICTION;
                if (prop <= 0.f) {
                        cam_rot_diff = C_vec3(0.f, 0.f, 0.f);
                        cam_momentum = FALSE;
                } else {
                        cam_rot_diff = C_vec3_scalef(cam_rot_diff, prop);
                        if (C_vec3_len(cam_rot_diff) < STOP_MARGIN) {
                                cam_rot_diff = C_vec3(0.f, 0.f, 0.f);
                                cam_momentum = FALSE;
                        }
                }
        } else
                cam_rot_diff = C_vec3(0.f, 0.f, 0.f);

        /* Apply the rotation differences from last frame to the rotation
           matrix to get view-oriented scrolling */
        glLoadMatrixf(cam_rotation);
        x_axis = C_vec3(cam_rotation[0], cam_rotation[4], cam_rotation[8]);
        y_axis = C_vec3(cam_rotation[1], cam_rotation[5], cam_rotation[9]);
        z_axis = C_vec3(cam_rotation[2], cam_rotation[6], cam_rotation[10]);
        glRotatef(C_rad_to_deg(diff.x), x_axis.x, x_axis.y, x_axis.z);
        glRotatef(C_rad_to_deg(diff.y), y_axis.x, y_axis.y, y_axis.z);
        glRotatef(C_rad_to_deg(diff.z), z_axis.x, z_axis.y, z_axis.z);

        /* If we are in gradual rotation mode, update it */
        if (cam_gradual) {
                float angle;

                angle = gradual_angle * GRADUAL_RATE * c_frame_sec;
                if (angle > gradual_angle)
                        angle = gradual_angle;
                glRotatef(C_rad_to_deg(angle), gradual_axis.x,
                          gradual_axis.y, gradual_axis.z);
                gradual_angle -= angle;
                if (gradual_angle < STOP_MARGIN)
                        cam_gradual = FALSE;
        }

        /* Recreate the full camera matrix with the new rotation */
        glGetFloatv(GL_MODELVIEW_MATRIX, cam_rotation);
        check_rotation();
        glLoadIdentity();
        glTranslatef(0, 0, -r_globe_radius - r_cam_zoom);
        glMultMatrixf(cam_rotation);
        glGetFloatv(GL_MODELVIEW_MATRIX, r_cam_matrix);

        /* Extract the camera location from the matrix for use by other parts
           of the program. We cannot replace these new vectors with the axes
           above because they are changed by the rotations. */
        r_cam_forward = C_vec3(-cam_rotation[2], -cam_rotation[6],
                               -cam_rotation[10]);
        r_cam_normal = C_vec3(cam_rotation[1], cam_rotation[5],
                              cam_rotation[9]);
        r_cam_origin = C_vec3_scalef(r_cam_forward,
                                     -r_globe_radius - r_cam_zoom);

        R_pop_mode();
}