1樓:匿名使用者
做個標記,我加你qq了 ,發到你郵箱去了~~~
2樓:匿名使用者
#include
main()}
3樓:
哇哇,分好多,給你一個
barycenter.c
#include
#include
#include
#include
//#define ndebug
#include
#include "barycenter.h"
struct barycenter cal_barycenter(struct point **, const int);
static struct barycenter cal_tri(struct point *, struct point *, struct point *);
static struct barycenter new_barycenter(const struct barycenter *, const struct barycenter *);
static struct point ** convert_list_to_arr(struct point_list *, const int);
void delete_point_arr(struct point **, const int);
int write_file(const char *);
int copy_file(const char *, const char *);
int read_data(struct point ***, const char *);
int fexist(const char *);
/*main function
*/int
main (int argc, char *argv)
else if (!flag)
printf("reading data from file...\n");
struct point ** point_arr = null;
int count;
struct barycenter result;
if (count < 3)
else
delete_point_arr(point_arr, count);
printf("exit.\n");
return rval;}/*
calculate the area and weight point of tri-angle.
a, b, c is the point.
return structure.
*/static struct barycenter cal_tri(struct point * a, struct point * b, struct point * c)
/*cal barycenter of multi tri-angle
*/struct barycenter cal_barycenter(struct point * point_arr, const int count)
if (i == count - 2)
if(sub_mtri_count >= 3)
free(sub_mtri);
return wpoint;}/*
cal new weight point and weight(area).
cal point a and point b and return the
result.
*/static struct barycenter new_barycenter(const struct barycenter * a, const struct barycenter * b)
/*write ori data to file file_name.
the ori data is a seril of point
which form a shape multi-tri-angle.
*/int write_file(const char * file_name)
int line = 0;
doint len;
for (i = 0; i < line; i++)
}free(head);
}else
printf("not enough lines. min is 3.\n");
}while (line < 3);
fflush(fp);
fclose(fp);
return 1;}/*
copy source file to dest file.
*/int copy_file(const char * src, const char * dst)
fflush(fp_dst);
goto exit;
error:
rval = 0;
exit:
if (fp_src != null)
fclose(fp_src);
if (fp_dst != null)
fclose(fp_dst);
return rval;}/*
read ori data from file
return count of points and point array
in this function, due to unpredictable count of points, i used
a structure of chain.
*/int read_data(struct point *** p_point_arr, const char * file_name)
int count = 0;
int flag1 = 0, flag2 = 0;
struct point_list * plist = null;
struct point_list * head = null;
struct point ptemp;
dowhile(flag2 != '\n' && flag2 != eof);
if (count == 0)
else
plist -> next = null;
plist -> point = ptemp;
count++;
}}while(flag1 != eof && flag2 != eof);
fclose(fp);
*p_point_arr = convert_list_to_arr(head, count);
return count;}/*
convert chain point list to point array
*/static struct point ** convert_list_to_arr(struct point_list * plist, const int count)
/*free the ori chain point_list
*/for (i = 0; i < count; i++)
return arr;}/*
delete point array
*/void delete_point_arr(struct point ** point_arr, const int count)}/*
test if file exist.
*/int fexist(const char * file_name)
}barycenter.h
struct point
;struct point_list
;struct barycenter;
c語言程式設計高手請進謝謝,C語言程式設計,高手請進,謝謝
根據樓上提供的進行優化,已經除錯成功的 去掉了註釋,考慮到各個機器的輸入法問題,所有的printf 內容都換成英文 include include include include define null 0 define len sizeof struct student define file d...
c語言的高手請進跪求幾道題的答案
wind戰神 我寫了幾個,都經過dev c除錯通過。第一題 include include int fib int n int main system pause return 0 第二題 include include int main printf 排序後 n for i 0 i 10 i pr...
c語言程式設計問題,高手請進
倒數第7行 有錯誤 定義的是i 不是y int s 1,i 我看了一下 你的 你的不完善 如果是2進位制 只能表達從 1 255 之間的數。如果是三進位制 也只能表達 0 19682 之間的數。 十進位制轉二進位制,知道演算法就很簡單啊 你想問什麼,能否具體點? 呼叫函式怎麼形參有一個y 函式體內又...