示例#1
0
void Vectorizer::load_data(const char* filename)
{
  FILE* f = fopen(filename, "rb");
  if (f == NULL) error("Could not open %s for reading.", filename);
  lock_data();

  struct { char magic[4]; int ver; } hdr;
  if (fread(&hdr, sizeof(hdr), 1, f) != 1)
    error("Error reading %s", filename);

  if (hdr.magic[0] != 'H' || hdr.magic[1] != '2' || hdr.magic[2] != 'D' || hdr.magic[3] != 'V')
    error("File %s is not a Hermes2D Vectorizer file.", filename);
  if (hdr.ver > 1)
    error("File %s -- unsupported file version.", filename);

  #define read_array(array, type, n, c, what) \
    if (fread(&n, sizeof(int), 1, f) != 1) \
      error("Error reading the number of " what " from %s", filename); \
    lin_init_array(array, type, c, n); \
    if (fread(array, sizeof(type), n, f) != n) \
      error("Error reading " what " from %s", filename);

  read_array(verts, double4, nv, cv, "vertices");
  read_array(tris,  int3,    nt, ct, "triangles");
  read_array(edges, int3,    ne, ce, "edges");
  read_array(dashes, int2,   nd, cd, "dashes");

  find_min_max();
  unlock_data();
  fclose(f);
}
void Wf_return::read(istream & is){
  int nfunc, nst;
  string dummy;
  is >> dummy >> nfunc;
  if(dummy != "nfunc") error("expected nfunc, got ", dummy);
  is >> dummy >> nst;
  Resize(nfunc, nst);
  is >> dummy >> is_complex;
  
  is >> dummy; read_array(is, nfunc, nst, amp);
  is >> dummy; read_array(is, nfunc, nst, phase);
  is >> dummy; read_array(is, nfunc, nst, cvals);
}
示例#3
0
void main()
{
	int a[201], n;

	clrscr();

	// se citeste sirul
	n = read_array(a);

	// daca a aparut o eroare la citirea datelor se iese din program
	if (n == -1)
	{
		printf("Eroare la citirea datelor!");
		getch();
		exit(1);
	}

	// se apeleaza algoritmul de sortare
	binary_insertion_sort(a, n);

	printf("\ncomparatii: %d\natribuiri: %d\n\nSirul ordonat: ", comp, atr);

	// se tipareste sirul sortat
	print_array(a, n, 1);
}
示例#4
0
/* tries to read a symbol's value */
static gboolean
read_value (CtplInputStream *stream,
            CtplValue       *value,
            GError         **error)
{
  GError *err = NULL;
  gchar   c;
  
  c = ctpl_input_stream_peek_c (stream, &err);
  if (err) {
    /* I/O error */
  } else if (c == CTPL_STRING_DELIMITER_CHAR) {
    read_string (stream, value, &err);
  } else if (c == ARRAY_START_CHAR) {
    read_array (stream, value, &err);
  } else if (c == '.' ||
             (c >= '0' && c <= '9') ||
             c == '+' || c == '-') {
    ctpl_input_stream_read_number (stream, value, &err);
  } else {
    ctpl_input_stream_set_error (stream, &err, CTPL_ENVIRON_ERROR,
                                 CTPL_ENVIRON_ERROR_LOADER_MISSING_VALUE,
                                 "No valid value can be read");
  }
  if (err) {
    g_propagate_error (error, err);
  }
  
  return ! err;
}
示例#5
0
JsonValue JsonValue::read(const std::string &json, size_t &pos)
{
	read_whitespace(json, pos);

	if (pos == json.length())
		throw JsonException("Unexpected end of JSON data");

	switch (json[pos])
	{
	case '{':
		return read_object(json, pos);
	case '[':
		return read_array(json, pos);
	case '"':
		return read_string(json, pos);
	case '-':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		return read_number(json, pos);
	case 'f':
	case 't':
		return read_boolean(json, pos);
	default:
		throw JsonException("Unexpected character in JSON data");
	}
}
示例#6
0
文件: Home2_2.cpp 项目: CAHbl4/C
void main()
{
	//Сохраняем текущие параметры консоли
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO csbi;
	if (GetConsoleScreenBufferInfo(hConsole, &csbi))
		currentConsoleAttr = csbi.wAttributes;

	//Объявляем массив
	static int arr[MAX_SIZE][MAX_SIZE];

	//Читаем с клавиатуры размер матрицы
	size_t n;
	printf(Rus("Введите размер матрицы (%d...%d). N: "), MIN_SIZE, MAX_SIZE);
	do
	{
		n = (size_t)read_int(stdin);
		if (n < MIN_SIZE || n > MAX_SIZE)
			printf(Rus("Неверный размер. Размер должен быть в диапазоне "
				"от %d до %d. Повторите ввод: \n"), MIN_SIZE, MAX_SIZE);
	} while (n < MIN_SIZE || n > MAX_SIZE);

	//Заполняем матрицу
	printf(Rus("Вводите элементы массива до заполнения\n"));
	UINT8 width = read_array(arr[0], n);

	//Выводим матрицу
	print_array(arr[0], n, TASK_ZONE, width);

	//Считаем значение из задания
	UINT64 sum = func_v13(arr[0], n, TASK_ZONE);

	printf(Rus("Сумма квадратов отрицательных чисел = %d\n"), sum);
}
示例#7
0
文件: parse.c 项目: NetSys/sts
static struct list_parse_dep
read_deps (char *s)
{
  char *save;
  struct list_parse_dep res = {0};
  for (char *depstr = strtok_r (s, "#", &save); depstr;
       depstr = strtok_r (NULL, "#", &save)) {
    char *save2;
    char *match, *portstr;
    int rule;

    rule = atoi (strtok_r (depstr, ";", &save2)) + 1;
    match = strtok_r (NULL, ";", &save2);
    portstr = strtok_r (NULL, ";", &save2);

    uint32_t ports[MAX_ARR_SIZE];
    struct arr_ptr_uint32_t nports = read_array (portstr, ports);

    struct parse_dep *tmp = xmalloc (sizeof *tmp + nports.n * sizeof *ports);
    tmp->rule = rule;
    tmp->match = array_from_str (match);
    tmp->nports = nports.n;
    memcpy (tmp->ports, ports, nports.n * sizeof *ports);

    list_append (&res, tmp);
  }
  return res;
}
示例#8
0
文件: problem5.c 项目: PoissonJ/notes
int main() {
  int size;

  scanf("%d", &size);
  read_array(size, size);
  printf("]\n");
}
示例#9
0
 BinaryInputStream&
 BinaryInputStream::read_record(Numeric::float64* data, int nbr) {
     begin_record();
     read_array(data, nbr);
     end_record();
     return *this;
 }
示例#10
0
文件: conf.c 项目: yoyofr/iNEOGEO
char* cf_parse_cmd_line(int argc, char *argv[]) {
	int c;
	CONF_ITEM *cf;


	option_index = optind = 0;
#ifdef WII
	return NULL;
#endif
	while ((c = getopt_long(argc, argv, shortopt, longopt, &option_index)) != EOF) {
		//if (c != 0) {
//			printf("c=%d\n",c);
			cf = cf_get_item_by_val(c&0xFFF);
			if (cf) {
				cf->flags |= CF_SETBYCMD;
//				printf("flags %s set on cmd line\n", cf->name);
				switch (cf->type) {

					case CFT_INT:
						CF_VAL(cf) = atoi(optarg);
						break;
					case CFT_BOOLEAN:
					if (c & 0x1000)
						CF_BOOL(cf) = 0;
					else
						CF_BOOL(cf) = 1;
						break;
					case CFT_STRING:
						strcpy(CF_STR(cf), optarg);
						//printf("conf %s %s\n",CF_STR(cf),optarg);
						break;
					case CFT_ARRAY:
						read_array(CF_ARRAY(cf), optarg, CF_ARRAY_SIZE(cf));
						break;
					case CFT_ACTION_ARG:
						strcpy(CF_STR(cf), optarg);
						if (cf->action) {
							exit(cf->action(cf));
						}
						break;
					case CFT_ACTION:
						if (cf->action) {
							exit(cf->action(cf));
						}
						break;
					case CFT_STR_ARRAY:
						/* TODO */
						break;
				}
			//}
		}
	}
	cf_cache_conf();
	if (optind >= argc)
		return NULL;

	return strdup(argv[optind]);
}
示例#11
0
int main(){
	int i,k,n,arr[50];
	printf("Enter the value of n : \t");
	scanf("%d",&n);
	printf("Enter the array : ");
	read_array(arr,n);	
	insertion_sort(arr,n);
	display_array(arr,n);
}
示例#12
0
void file_input(FILE* file, char* header, char A[MAX_N], char B[MAX_N]  ){
	char buf[256];
	int a, b, num_success;
	header[0] = 0;
	do{
		fgets(buf, MAX_N, file);
		strcat(header, buf);
	} while(strcmp(buf, "\n"));
	//read the numbers
	num_success = fscanf(file, "%d %d", &a, &b);
	if (num_success < 2)
		fail("Failed to read array sizes from input string. Closing...");
	fgets(buf, 256, file);
	fgets(buf, 256, file); //array a
	read_array(buf, A, a, "A");
	fgets(buf, 256, file); //array b
	read_array(buf, B, b, "B");
};
示例#13
0
文件: lista2.04.c 项目: jucimarjr/pca
int main(int argc, const char *argv[])
{
	int *v1, *v2, n, cont; //vetor 1, vetor 2, numero de elementos, contador;

	puts("Informe o tamanho do vetor:");
	scanf("%d", &n);	

	v1 = (malloc(sizeof(int) * n)); //alocar n endereços de memoria para o vetor 1;
	v2 = (malloc(sizeof(int) * n)); //alocar n endereços de memoria para o vetor 2;
    printf ( "Lendo o primeiro vetor...\n" );
	read_array(n, v1); //vetor 1 recebe os valores;
    printf ( "Lendo o segundo vetor...\n" );
	read_array(n, v2); //vetor 2 recebe os valores;

	printf("O produto escalar é: %d\n", produto_escalar(n, v1, v2)); // printa o retorno da função produto escalar que recebe os dois vetores e o tamanho deles e depois calcula o produto escalar.

	return 0;
}
示例#14
0
文件: menu.cpp 项目: Nrpickle/CS163
//Reads in the command information from the user
//Helps make the program easier to read
int menuType::readCommandInfo(commandType & tempCommand)
{
  char * temp = new char [TEMP_SIZE];   //Used to store information from the user
  int len = 0;                          //Used to 'measure' the arrays

  //Reads in the infromation from the user and stores it in the passed command  
  read_array("Command function: ", temp, TEMP_SIZE);
  len = strlen(temp);
  tempCommand.func = new char[len+1];
  strcpy(tempCommand.func, temp);
  
  read_array("Defined rules: ", temp, TEMP_SIZE);
  len = strlen(temp);
  tempCommand.rules = new char[len+1];
  strcpy(tempCommand.rules, temp);
  
  delete [] temp;
}
示例#15
0
      void Orderizer::load_data(const char* filename)
      {
        FILE* f = fopen(filename, "rb");
        if (f == NULL) error("Could not open %s for reading.", filename);
        lock_data();

        struct { char magic[4]; int ver; } hdr;
        if (fread(&hdr, sizeof(hdr), 1, f) != 1)
          error("Error reading %s", filename);

        if (hdr.magic[0] != 'H' || hdr.magic[1] != '2' || hdr.magic[2] != 'D' || hdr.magic[3] != 'O')
          error("File %s is not a Hermes2D Orderizer<Scalar> file.", filename);
        if (hdr.ver > 1)
          error("File %s -- unsupported file version.", filename);

#define read_array(array, type, n, c, what) \
  if (fread(&n, sizeof(int), 1, f) != 1) \
  error("Error reading the number of " what " from %s", filename); \
  lin_init_array(array, type, c, n); \
  if (fread(array, sizeof(type), n, f) != (unsigned) n) \
  error("Error reading " what " from %s", filename);

        read_array(verts, double3, nv, cv,  "vertices");
        read_array(tris,  int3,    nt, ct,  "triangles");
        read_array(edges, int3,    ne, ce,  "edges");
        read_array(lvert, int,     nl, cl1, "label vertices");

        lin_init_array(lbox, double2, cl3, nl);
        if (fread(lbox, sizeof(double2), nl, f) != (unsigned) nl)
          error("Error reading label bounding boxes from %s", filename);

        int* orders = new int[nl];
        if (fread(orders, sizeof(int), nl, f) != (unsigned) nl)
          error("Error reading element orders from %s", filename);

        lin_init_array(ltext, char*, cl2, nl);
        for (int i = 0; i < nl; i++)
          ltext[i] = labels[H2D_GET_H_ORDER(orders[i])][H2D_GET_V_ORDER(orders[i])];

        find_min_max();
        unlock_data();
        fclose(f);
      }
示例#16
0
文件: a2.cpp 项目: asrathor/CSE-250
int main(int argc, char* argv[]) {
	A2 A = create_array();  
	write_array(A);

    std::cout << ((read_array(A) == 1) ? "ok" : "error") << std::endl;
    std::cout << ((A.rsum(N - 1) == 1) ? "ok" : "error") << std::endl;
    std::cout << ((A.csum(M - 1) == 1) ? "ok" : "error") << std::endl;

    return 0;
} // main
示例#17
0
文件: menu.cpp 项目: Nrpickle/CS163
int menuType::addNew(mappingType & map)
{
  int status = 0;

  dataType newData;


  //Name
  newData.name = new char[TEMP_SIZE];
  read_array("Name: ", newData.name, TEMP_SIZE);
  //Type
  newData.type = new char[TEMP_SIZE];
  read_array("Type: ", newData.type, TEMP_SIZE);
  //Memory Location
  newData.memoryLocation = rand() % 100000;   

  status = map.insertItem(newData);  //Insert the data into the ADT

  return status;
}
示例#18
0
static ctache_data_t
*read_object(struct json_parser *parser)
{
	ctache_data_t *data;
	struct json_token *tok;
	char *key;
	ctache_data_t *val;
	int done = 0;
	size_t len;

	data = ctache_data_create_hash();

	while (!done) {
		tok = json_next_token(parser);
		key = strdup(tok->value.string);
		tok = json_next_token(parser);
		if (tok->type != JSON_COLON) {
			fprintf(stderr, "ERROR: Expected ':'\n");
			ctache_data_destroy(data);
			free(key);
			return NULL;
		}
		tok = json_next_token(parser);
		if (tok->type == JSON_STRING) {
			len = strlen(tok->value.string);
			val = ctache_data_create_string(tok->value.string, len);
		} else if (tok->type == JSON_BOOLEAN) {
			val = ctache_data_create_boolean(tok->value.boolean);
		} else if (tok->type == JSON_BRACE_LEFT) {
			val = read_object(parser);
		} else if (tok->type == JSON_BRACKET_LEFT) {
			val = read_array(parser);
		} else {
			fprintf(stderr, "ERROR: Expected value\n");
			ctache_data_destroy(data);
			free(key);
			return NULL;
		}
		ctache_data_hash_table_set(data, key, val);
		free(key);

		tok = json_next_token(parser);
		if (tok->type == JSON_BRACE_RIGHT) {
			done = 1;
		} else if (tok->type == JSON_COMMA) {
			done = 0;
		} else {
			fprintf(stderr, "ERROR: Expected '}'\n");
			ctache_data_destroy(data);
			return NULL;
		}
	}
	return data;
}
示例#19
0
static VALUE
pg_text_dec_array_helper(t_pg_type *conv, char *val, int len, int tuple, int field, int enc_idx, t_pg_type_dec_func dec_func)
{
	/* create a buffer of the same length, as that will be the worst case */
	char *word = xmalloc(len + 1);
	int index = 1;

	VALUE return_value = read_array(conv, &index, val, len, word, enc_idx, tuple, field, dec_func);
	free(word);
	return return_value;
}
示例#20
0
文件: Exam.cpp 项目: CAHbl4/C
state input_arr(void* data, void* params)
{
	cci.dwSize = 5;
	cci.bVisible = TRUE;
	SetConsoleCursorInfo(hConsole, &cci);
	system("cls");
	flush_stream(stdin);
	printf(Rus("Вводите числа и они будут записаны в массив.\n"));
	printf(Rus("Для прекращения ввода-<Enter> в начале строки.\n"));
	arr = read_array(arr, &arr_count);
	return REDRAW_ALL;
}
示例#21
0
int read_variant_array(DBusMessageIter * args, char *connections[30])
{
	DBusMessageIter subiter;
	int num_of_conn;
	int type = dbus_message_iter_get_arg_type(args);
	if (type == DBUS_TYPE_VARIANT) {
		dbus_message_iter_recurse(args, &subiter);
            int sub_type = dbus_message_iter_get_arg_type(&subiter);
            if (sub_type == DBUS_TYPE_ARRAY)
                 num_of_conn = read_array(&subiter, connections);
	}
return(num_of_conn);     
}
示例#22
0
void retrieve_heaps(const jsa_counterexamplet &ce,
    __CPROVER_jsa_abstract_heapt *heaps)
{
  assert(std::is_sorted(ce.begin(), ce.end(), compare_assignment));
  size_t index=0;
  for (const jsa_counterexamplet::value_type &assignment : ce)
    if (is_heap(assignment))
    {
      const struct_exprt &value=to_struct_expr(assignment.second);
      __CPROVER_jsa_abstract_heapt &heap=heaps[index++];
      struct_exprt::operandst ops(value.operands());
      remove_padding(ops, value.type());
      assert(NUM_ABSTRACT_HEAP_MEMBERS == ops.size());
      read_array(heap.concrete_nodes, ops[CONCRETE_NODES_COMP_INDEX]);
      read_array(heap.abstract_nodes, ops[ABSTRACT_NODES_COMP_INDEX]);
      read_array(heap.abstract_ranges, ops[ABSTRACT_RANGES_COMP_INDEX]);
      read_array(heap.iterators, ops[ITERATORS_COMP_INDEX]);
      heap.iterator_count=to_integer(ops[ITERATOR_COUNT_COMP_INDEX]);
      read_array(heap.list_head_nodes, ops[LIST_HEAD_NODES_COMP_INDEX]);
      heap.list_count=to_integer(ops[LIST_COUNT_COMP_INDEX]);
    }
}
示例#23
0
/*
 * read a value and add it to tree
 */
static int
read_value(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree,
           int asWhat)
{
  guint8 type_code;

  type_code = tvb_get_guint8(tvb, *offset);
  if (type_code <= ETCH_TC_MAX_TINY_INT ||
      type_code >= ETCH_TC_MIN_TINY_INT) {
    /* this is the value already */
    proto_tree_add_item(etch_tree, asWhat, tvb, *offset, 1, ENC_BIG_ENDIAN);
    (*offset)++;
    return type_code;
  }

  switch(type_code) {
  case ETCH_TC_CUSTOM:
    read_struct(offset, tvb, etch_tree, 1);
    break;
  case ETCH_TC_ARRAY:
    read_array(offset, tvb, etch_tree);
    break;
  case ETCH_TC_STRING:
    read_string(offset, tvb, etch_tree);
    break;
  case ETCH_TC_FLOAT:
    read_number(offset, tvb, etch_tree, hf_etch_float, type_code);
    break;
  case ETCH_TC_DOUBLE:
    read_number(offset, tvb, etch_tree, hf_etch_double, type_code);
    break;
  case ETCH_TC_SHORT:
    read_number(offset, tvb, etch_tree, hf_etch_short, type_code);
    break;
  case ETCH_TC_INT:
    read_number(offset, tvb, etch_tree, hf_etch_int, type_code);
    break;
  case ETCH_TC_LONG:
    read_number(offset, tvb, etch_tree, hf_etch_long, type_code);
    break;
  case ETCH_TC_BYTE:
    read_number(offset, tvb, etch_tree, hf_etch_byte, type_code);
    break;
  case ETCH_TC_BYTES:
    read_bytes(offset, tvb, etch_tree);
    break;
  default:
    read_number(offset, tvb, etch_tree, asWhat, type_code);
  }
  return 0;
}
示例#24
0
文件: merge.c 项目: k-okada/Software2
int main(int argc, char *argv[]) {
    int length, *num;
    char *fname="rand.txt";

    printf("reading from %s\n", fname);
    num = read_array(fname, num, &length);

    print_array(num, length);
    merge_sort(num, 0, length-1);
    print_array(num, length);

    free(num);
    return 0;
}
示例#25
0
static void
read_next(ParseInfo pi, const char *key) {
    VALUE	obj;

    if ((void*)&obj < pi->stack_min) {
	rb_raise(rb_eSysStackError, "JSON is too deeply nested");
    }
    next_non_white(pi);	/* skip white space */
    switch (*pi->s) {
    case '{':
	read_hash(pi, key);
	break;
    case '[':
	read_array(pi, key);
	break;
    case '"':
	read_str(pi, key);
	break;
    case '+':
    case '-':
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
	read_num(pi, key);
	break;
    case 'I':
	read_num(pi, key);
	break;
    case 't':
	read_true(pi, key);
	break;
    case 'f':
	read_false(pi, key);
	break;
    case 'n':
	read_nil(pi, key);
	break;
    case '\0':
	return;
    default:
	return;
    }
}
示例#26
0
int main (int argc, char* argv[])
{
	//create a pointer, which will be used to store the array
	int *A;

	//check if the user ran the program correctly
	if (argc < 2) {
		fprintf(stderr, "Usage: mean_median file1 [file2 ...]\n");
	}

	//if the program is run correctly argv[1] will be the first
	//command line argument. ie name of the input file
	char *file = argv[1];

	//open file for reading
	FILE *fp = fopen(file, "rb");
	if (fp == NULL)
		return 1;

	//call read_array function which will allocate space for A
	//read the file and put the numbers in array A
	//the read_array function must return the size of the array
	int n = read_array(fp, &A);
	if (n < 0) {
		return 1;
	}

	//print array A of size n
	print_array(A, n);
	
	//sort
	select_sort(A, n);
	
	//print again
	print_array(A, n);

	//calculate mean and median of array A
	double mean = mean_array(A, n);
	double med = median_array(A, n);

	//print results
	printf("mean = %f med = %f\n", mean, med);

	//cleanup
	free(A);
	fclose(fp);

	return 0;
}
示例#27
0
main()
{
	int size_local;
	char letters[MAX_DATA];
	
	int upper[MAX_LETTERS] = {0};
	int lower[MAX_LETTERS] = {0};

	read_array(letters, &size_local);

	process_array(letters, size_local, upper, lower);

	print_array(upper, lower);
 
	return(0);
}
示例#28
0
文件: problem5.c 项目: PoissonJ/notes
void read_array(int size, int numberOfRuns) {
  //Implement read_array here
  int element;
  if (size == 0) {
      printf("[");
  } else {
      scanf("%d", &element);
      read_array(size - 1, numberOfRuns);

      // Last run so do not print the trailing comma
      if (size == numberOfRuns) {
        printf("%d", element);
      } else {
        printf("%d,", element);
      }
  }
}
示例#29
0
文件: rich_json.c 项目: vaughan0/vlib
static void read_value(void* _self, rich_Sink* to) {
  JSONSource* self = _self;
  Input* in = self->in;
  int ch = skip_whitespace(in);
  bool bval;
  switch (ch) {
    case -1:
      RAISE(EOF);

    case 'n':
      read_primitive(in, "ull");
      call(to, sink, RICH_NIL, NULL);
      break;
    case 't':
      read_primitive(in, "rue");
      bval = true;
      call(to, sink, RICH_BOOL, &bval);
      break;
    case 'f':
      read_primitive(in, "alse");
      bval = false;
      call(to, sink, RICH_BOOL, &bval);
      break;

    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8': case '9':
    case '+': case '-':
      read_number(in, ch, to);
      break;

    case '"':
      read_string(self);
      call(to, sink, RICH_STRING, &self->sval);
      break;

    case '[':
      read_array(self, to);
      break;
    case '{':
      read_map(self, to);
      break;

    default:
      RAISE(MALFORMED);
  }
}
示例#30
0
int main(int argc,char **argv)
{
	int i;
	

	if(argc<2)
	{
		printf("Arguments are: sorter file_name\n");
		return 1;
	}	
	
	

	if(read_array(&array,&array_length,argv[1]))
	{
		fprintf(stderr,"Can't read array from file '%s'\n",argv[1]);
		return -1;
	}

	while(num_swaps)
	{
		num_swaps=0;
		for(i=1;i<array_length;i++)
		{
			if(array[i]<array[i-1])
			{
				int val;
				val=array[i];
				array[i]=array[i-1];
				array[i-1]=val;
				num_swaps++;
			}	
		}
		printf("num_swaps %d\n",num_swaps);		
	}	
	
	for(i=0;i<array_length;i++)
	{
		printf("array[%d]=%d\n",i,array[i]);
	}
	
	free(array);	

	return 0;
}