線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:751
推到 Plurk!
推到 Facebook!

請大大救命一個c++的問題

缺席
tommylee926
一般會員


發表:24
回覆:25
積分:9
註冊:2003-08-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-01-07 13:04:10 IP:163.22.xxx.xxx 未訂閱
#include #include<math.h> const int N = 10000; int N2; float all = 0.0; //所有的number的總發生次數 int index = 0; //計算不重覆的number有几個 int index_b = 0;//系數 int allofsource = 0; bool isfind; float v = 0.1;//想求的值 struct p { float number; float counter; float binding; float pro; }; //存方程式系數 struct l { float pro; float sij; }; float binary(float w , l *b) { static float l = 0; static float r = 1; double temp = 0; for(int i = 0;i < N2;i ) temp = temp b[i].pro * pow(2.71 , w * b[i].sij); cout<= 0.9999 && temp <= 1 ) return w; if(temp < 1) { l = w; w = l (r - l) / 2.0; } else if(temp > 1) { r = w; w = l (r - l) / 2.0; } binary(w , b); } void main() { p *a = new p[N]; for(int i = 0;i < N;i ) { a[i].number = 1; a[i].counter = 0; } int number,binding; FILE *infile = fopen("d:\\a.txt","rt"); //計算所有number發生的數目 while(fscanf(infile,"%d%d",&number,&binding) != EOF) { isfind = false; for( int i = 0;i < N;i ) { if(a[i].number == number) { a[i].counter ; isfind = true; break; } } if(!isfind) { a[index].number = number; a[index].counter ; a[index].binding = binding; index ; } } fclose(infile); for(int i = 0; i < index; i ) all = all a[i].counter; for(int i = 0; i < index; i ) a[i].pro = a[i].counter / all ; N2 = index * index ; l *b = new l[N2];//存系數 for(int i = 0; i < index ; i ) for(int j = 0; j < index ; j ) { b[index_b].pro = a[i].pro * a[j].pro; if(a[i].number == a[j].number) b[index_b].sij = 10; else if(a[i].binding == a[j].binding) b[index_b].sij = 2; else b[index_b].sij = -9; index_b ; } delete []a; v = binary(v,b); delete []b; cout<>index; } ============================================================= 上面是c 程式碼,用builder 跑時會發生錯誤,但我找了很久,不知錯在哪 不知有哪位大大可以幫忙解決,謝謝囉 ^^
系統時間:2024-06-27 1:10:12
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!