#401356 · 16 Mar 2004, 02:14 · · პროფილი · პირადი მიმოწერა · ჩატი
pomogite sovetom(otvetom );
Est vopros ! obiavlen dvumerni massiv price ! vobshem zadacha komivoiaja ! kogda masiv PRICE ispolzuet fukcia GTS() on kakim to obrazom unichtojaetsia !
esli ne ispolzuiu fukciu GTS(); togda masiv sushestvuet bez problem (read/write)! XOTIA SAMOE INTERESENOE OTVET VIDAIOT PRAVILNO sam GTS tak chto kak algoritm nekakix problem ne vizivaet ! prosto posle kak poluchaiu otvet ! masiv okazvaetsia unichtojenim !
xotia negda v GTS masiv PRICE ne portitsia !
price = (int*)malloc(m_iNumber*m_iNumber*sizeof(int)); b = (int*) malloc (m_iNumber*sizeof(int)); c = (int*) malloc ((m_iNumber+1)*sizeof(int));
void CKomivoyagerDlg::gts() { int k,s,min; UINT i,j;
////////////////////tut masiv est ! !!!! a v konce fukcii GTS() on kakim to obrazom unichtojaetsia
for(UINT e=0;e<m_iNumber;e++) for(UINT q=0;q<m_iNumber;q++) {char buffer[20]; itoa( *(price+e*m_iNumber+q),buffer,10); AfxMessageBox(buffer);} //////////////////
*(b+0*m_iNumber)=1; *(c+0*m_iNumber)=1;
for(i=1;i<m_iNumber;i++) *(b+i*m_iNumber)=0; k=0;
for(i=1;i<m_iNumber;i++) { min=32767; for(j=1;j<m_iNumber;j++) { if (*(b+j*m_iNumber)==0) if (min> *(price+k*m_iNumber+j) ) { min=*(price+k*m_iNumber+j); k=j; } } *(b+k*m_iNumber)=1; *(c+i*m_iNumber)=k+1; } *(c+m_iNumber*m_iNumber)=1;
s=0; for(i=0;i<m_iNumber;i++) s=s+*(price+(*(c+i*m_iNumber)-1)*m_iNumber+(*(c+(i+1)*m_iNumber)-1) ); char str[20]; itoa(s,str,10); st->SetWindowText(str); // xotia otvet pravilni v STR
// tut uje ego netu , eshe daje s fukcii ne vishel uje massiva netu!
for(UINT e=0;e<m_iNumber;e++) for(UINT q=0;q<m_iNumber;q++) {char buffer[20]; itoa( *(price+e*m_iNumber+q),buffer,10); AfxMessageBox(buffer);} } // xotia inogda on est esli skajem m_iNumber ( UINT ) = 10 , ili 5 , na drugie chisla ego chashe netu chem est ! vobshem ne smog razobratsia
|