C語言高手請進100分跪求課程設計急急急可追加分

時間 2021-07-23 23:18:23

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;

count = read_data(&point_arr, data_file_name);

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語言問題高手請進

我給你解釋一下 我假設有a,b兩個數,設t為他們的任一公約數那麼肯定有下列式子成立 a t x1 b t x2 其中x1,x2都為整數,我們不妨假設a b a b的情況是一樣的 此時顯然有x1 x2 我用上面的式子 下面的式子 則有a b t x1 x2 很顯然t也是a b的公約數,而且它也是b的公...

C語言的高手請進!高分!急 急 急

include char fun int n main 編譯通過 include include char fun int n main 執行結果 no yes press any key to continue 首先你的演算法有點問題,會有4舍5入現象 取決於編譯軟體,系統 其次,指標返回有問題,...

關於C語言的結構體高手請進

可以實現 struct student s1 scanf c,d s1.name,s1.number 注意輸入時候以逗號分隔 一定要使用 student next這個結構指標,而且要求不破壞student這個結構的定義嗎?這樣子如果再想加入性別年齡這種資料,恐怕比較不合適,而且程式看起來也不清晰 一...