C_and_CPP 板


LINE

#include<iostream> #include <iomanip> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <conio.h> #include <string.h> #include <fstream> #include <math.h> using std::cout; using std::endl; using namespace std; int main(void) { float r[31] = {-0.63121,-0.40549,2.7277,0.78316,1.31013,-1.58676,-0.39346 ,-0.8032,0.79537,-1.37385,1.48174,1.83644,0.82119,0.30444,-0.75855,1.05733 ,1.06721,-0.4587,0.77037,0.81001,-1.47255,-1.99684,2.42261,0.6552,0.14404 ,-2.18021,0.99614,0.37678,0.14944,1.73383,-1.17308}; int s0[1][32]={0};//[a0][time] int s1[1][32]={0};//[a1][time] int s2[1][32]={0};//[a2][time] int s3[1][32]={0};//[a3][time] int s4[1][32]={0};//[a4][time] int s5[1][32]={0};//[a5][time] int s6[1][32]={0};//[a6][time] int s7[1][32]={0};//[a7][time] int s8[1][32]={0};//[a8][time] int s9[1][32]={0};//[a9][time] int s10[1][32]={0};//[a10][time] float s[2048][32]={0};//[a10][time]//總和 int v[2048][31]={0};// float b[2][31]={0};//[branch][time] float state[1][32]={0}; int codeword[1][31]={0}; double max = 2.0; for(int i=1;i<=31;i++) { b[0][i] = -1*r[i-1];//計算V=0的branch b[1][i] = 1*r[i-1];//計算V=1的branch } /////////////////////////////////////////////////// for(int t=1;t<=11;t++)///// { max = pow(2.0, t); for(int i=0;i<=(max/2)-1;i++) { int y=0; s0[i][t] = (i/1)%2; s1[i][t] = (i/2)%2; s2[i][t] = (i/4)%2; s3[i][t] = (i/8)%2; s4[i][t] = (i/16)%2; s5[i][t] = (i/32)%2; s6[i][t] = (i/64)%2; s7[i][t] = (i/128)%2; s8[i][t] = (i/256)%2; s9[i][t] = (i/1024)%2; s10[i][t] = (i/2048)%2; //////////////////////////////////////////////////////////////////////// if(t==1) //2 1bits { v[i][t] = s0[i][t]; s[i][t] = s[i][t-1]+b[y][t]; v[i+1][t] = ((v[i][t])+1)%2; s[i+1][t] = s[i][t-1]+b[(y+1)%2][t]; } //////////////////////////////////////////////////////////////////////// if(t==2)//4 2bits { y = v[i][t] = s1[i][t]; s[i][t] = s[i][t-1] + b[y][t]; v[i+2][t] = ((v[i][t])+1)%2; s[i+2][t] = s[i][t-1] + b[(y+1)%2][t]; } //////////////////////////////////////////////////////////////////////// if(t==3)//8 3bits { y = v[i][t] = (s0[i][t]+s2[i][t])%2; s[i][t] = s[i][t-1] + b[y][t]; v[i+4][t] = ((v[i][t])+1)%2; s[i+4][t] = s[i][t-1] + b[(y+1)%2][t]; } //////////////////////////////////////////////////////////////// if(t==4)//16 4bits { y = v[i][t] = (s1[i][t]+s3[i][t])%2; s[i][t] = s[i][t-1] + b[y][t]; v[i+8][t] = ((v[i][t])+1)%2; s[i+8][t] = s[i][t-1] + b[(y+1)%2][t]; } ////////////////////////////////////////////////////////////////////////////////////// if(t==5)//32 5bits { y = v[i][t] = (s0[i][t]+s2[i][t]+s4[i][t])%2; s[i][t] = s[i][t-1] + b[y][t]; v[i+16][t] = ((v[i][t])+1)%2; s[i+16][t] = s[i][t-1] + b[(y+1)%2][t]; } ////////////////////////////////////////////////////////////////////////////////////// if(t==6)//64 6bits { y = v[i][t] = (s1[i][t]+s3[i][t]+s5[i][t])%2; s[i][t] = s[i][t-1] + b[y][t]; v[i+32][t] = ((v[i][t])+1)%2; s[i+32][t] = s[i][t-1] + b[(y+1)%2][t]; } 小弟先做compiler然後在(t==6)那邊設了一個中斷點 然後F5一步一步跑,但是每試跑到t==6那邊i不固定是多少 就會跑出底下的錯誤訊息 indows has triggered a breakpoint in helloC++.exe. This may be due to a corruption of the heap, which indicates a bug in helloC++.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while helloC++.exe has focus. The output window may have more diagnostic information. helloC++.exe是我的專題名,我有爬文只知道heap好像是一種記憶體的方式 但是還是不太知道為什麼它會爆 可以請板上的高手解答一下嗎 小弟還是VC新手 所以請板上高手盡量告訴 感謝^^ Unhandled exception at 0x002718f7 in helloC++.exe: 0xC0000005: Access violation writing location 0x00160004. 有時後又會出現這種,真的是很頭痛 --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.122.235 ※ 編輯: gw119 來自: 140.113.122.235 (04/30 20:50)
1F:推 Laputaet3:s0~s1 只宣告 [1][32] 卻用超過, in 第一次的雙層for 04/30 21:52
2F:→ gw119:後來我才發現這個低級的錯XD 04/30 22:01
3F:→ gw119:真的是大感謝 看樣子我還要多多加強阿 感謝感謝 04/30 22:02
4F:→ james732:老實說陣列越界一點都不低級...我寫了四年還是會犯 orz 04/30 22:51
5F:→ james732:這時就會覺得 C#/Java 會丟例外真是太貼心了 XD 04/30 22:52







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:iOS站內搜尋

TOP