Exemplo n.º 1
0
//#if 0
int main(void) {
  
  union data_32bit a,b;
  union data_32bit diff;

  int select_flag;
  char select_buf[10];
  printf("select import form :\n");
  printf("float -> 0\n");
  printf("32bit -> 1 (others)\n");
  gets(select_buf);
  sscanf(select_buf, "%d\n", &select_flag);

  if (select_flag == 0) {
    printf("a.fl32 : "); scanf("%f", &a.fl32);
    printf("b.fl32 : "); scanf("%f", &b.fl32);
  } else {
    char a_str[35], b_str[35];
    printf("詰めて入力しても可\n");
    printf("- --exp--- -------fraction--------\n");
    printf("a(32bit) :\n");
    gets(a_str);
    printf("b(32bit) :\n");
    gets(b_str);
    a.uint32 = str_to_uint32(delete_space(a_str));
    b.uint32 = str_to_uint32(delete_space(b_str));
  }
    
  printf("\n");

  printf("-- a --\n");
  print_data(a);
  
  printf("\n");

  printf("-- b --\n");
  print_data(b);

  printf("\n");

  diff.uint32 = fsub(a.uint32, b.uint32);
  
  printf("-- diff --\n");
  print_data(diff);

  printf("\n");

  union data_32bit test;

  printf(" -- correct answer --\n");
  test.fl32 = a.fl32 - b.fl32;
  print_data(test);

  return(0);
}
Exemplo n.º 2
0
void input(struct students *person, int records)
{
    char *string;
    do{
           string=(char*)calloc(20,sizeof(char));
    }while(!string);
    int number=0,num;
    puts("enter surname ");
    string = check_input();
    strcpy(person[records].fullname.surname, delete_space(string));
    puts("enter name ");
    string = check_input();
    strcpy(person[records].fullname.name, delete_space(string));
    puts("enter patronymic ");
    string = check_input();
    strcpy(person[records].fullname.patronymic, delete_space(string));
    puts("1-height,weight 2-height,weight,other characteristics");
    num=atoi(check_input());
    if(num==1)
    {
        person[records].union_num=1;
        puts("enter height");
        number=atoi(check_input());
        person[records].characteristics.characteristics_1.height=number;
        puts("enter weight");
        number=atoi(check_input());
        person[records].characteristics.characteristics_1.weight=number;
    }
    else
    {
        person[records].union_num=2;
        puts("enter height");
        number=atoi(check_input());
        person[records].characteristics.characteristics_2.height=number;
        puts("enter weight");
        number=atoi(check_input());
        person[records].characteristics.characteristics_2.weight=number;
        puts("enter age");
        number=atoi(check_input());
        person[records].characteristics.characteristics_2.age=number;
        puts("enter pulse");
        number=atoi(check_input());
        person[records].characteristics.characteristics_2.pulse=number;
    }
}
Exemplo n.º 3
0
void input(struct staff *person, char *string, int records)
{
    int i = 0;
    puts("enter surname ");
    string = check_input(person, records);
    strcpy(person[records].surname, delete_space(string));
    puts("enter name ");
    string = check_input(person, records);
    strcpy(person[records].name, delete_space(string));
    puts("enter patronymic ");
    string = check_input(person, records);
    strcpy(person[records].patronymic, delete_space(string));
    printf
        ("enter salary per month\nATTENCION:maximum length of salary cannot exceed 14 symbols\n");
    for (i = 0; i < 12; i++) {
        printf("\n month[%d]=", i + 1);
        string = check_input(person, records);
        person[records].salary[i] = atoi(string);
    }
}
Exemplo n.º 4
0
int main(void) {
  
  union data_32bit a;
  union data_32bit neg;

  int select_flag;
  char select_buf[10];
  printf("select import form :\n");
  printf("float -> 0\n");
  printf("32bit -> 1 (others)\n");
  gets(select_buf);
  sscanf(select_buf, "%d\n", &select_flag);

  if (select_flag == 0) {
    printf("a.fl32 : "); scanf("%f", &a.fl32);
  } else {
    char a_str[35];
    printf("詰めて入力しても可\n");
    printf("- --exp--- -------fraction--------\n");
    printf("a(32bit) :\n");
    gets(a_str);
    a.uint32 = str_to_uint32(delete_space(a_str));
  }
    
  printf("\n");

  printf("-- a --\n");
  print_data(a);
  
  printf("\n");

  neg.uint32 = fneg(a.uint32);
  
  printf("-- neg --\n");
  print_data(neg);

  printf("\n");

  union data_32bit test;

  printf(" -- correct answer --\n");
  test.fl32 = a.fl32 * (-1);
  print_data(test);

  return(0);
}
void store_variable_in_tree(Trie* _variable, char *_declaration_sentence)
{
	delete_se(_declaration_sentence);
	int cnt_se = count_symbol_num(_declaration_sentence);
	enum Type type = declaration_variable_type(_declaration_sentence);
	char **variable_name = (char **)malloc(sizeof(char*)*(cnt_se + 1));
	int flag = 0;
	char *variable_sentence = declaration_variable_start(_declaration_sentence);
	delete_space(variable_sentence);
	for (unsigned i = 0; i < strlen(variable_sentence); i++)
	{
		if (i == 0 && variable_sentence[i] == ',')
		{
			flag = 1;
		}
		else if(variable_sentence[i]==','&&variable_sentence[i+1]==',')
		{
			flag = 1;
		}
	}
	if (flag == 0)
	{
		variable_name = string_division(variable_sentence);

		for (int j = 0; j < cnt_se + 1; j++)
		{
			if (!strcmp(*(variable_name + j), "int") || !strcmp(*(variable_name + j), "double") || !strcmp(*(variable_name + j), "print"))
			{
				printf("ERROR In Line %d : The variable's name is illegal.\n",line_cnt);
				exit(1);
			}
			else
			{
				add_variable(type, *(variable_name + j), _variable);
			}
		}
	}
	else
	{
		printf("ERROR In Line %d : The variable's name is illegal.\n",line_cnt);
		exit(1);
	}
}
Exemplo n.º 6
0
/* モンスターのデータをロード(未完成) */
void load_monster_data()
{
  FILE *file;
  char buf[128];
  
  file = fopen( "monsterdata", "r" );
  if( file == NULL )
    return;                     //ERROR

  int n,h,a,d,m,e;
  char nm[64];
  
  while( fgets( buf, sizeof(buf), file ) != NULL ) {
    delete_space( buf );        /* 空白を削除する */
    sscanf(buf, "%d,%[^,],%d,%d,%d,%d,%d", &n,nm,&h,&a,&d,&m,&e );
    //    printf("%d %s %d %d %d %d %d\n",n,nm,h,a,d,m,e);
  }

  fclose( file );
}
Exemplo n.º 7
0
 virtual ~PopulationSpace() {
     delete_space( free_space );
     delete_space( pheno_space );
 }