C ++ dynamically generates one-dimensional arrays and two-dimensional array instances

Source: Internet
Author: User

# Include <iostream> <br/> using namespace STD; <br/> # define d_af 0.85; // attenuation factor <br/> # define end 0.0000000001 // end condition <br/> int main () {<br/> int pagenum, count; <br/> cout <"Enter the number of webpages and iterations" <Endl; <br/> CIN> pagenum> count; </P> <p> // assign an initial value to PageRank <br/> double * PageRank; <br/> PageRank = new double [pagenum]; <br/> for (INT I = 0; I <pagenum; I ++) {<br/> PageRank [I] = 1; <br/>}</P> <p> // dynamically generates two arrays <br/> int ** linkarray; <br/> linkarray = new int * [pagenum]; <br/> for (I = 0; I <pagenum; I ++) <br/>{< br/> linkarray [I] = new int [pagenum]; <br/>}</P> <p> cout <"Enter the link structure matrix" <Endl; // 0 1 <br/> for (I = 0; I <pagenum; I ++) {<br/> for (Int J = 0; j <pagenum; j ++) {<br/> // CIN> * (linkarray + I) + J ); // you can use either of the input matrix expressions <br/> CIN> linkarray [I] [J]; <br/>}< br/> cout <Endl; <br/>}< br/>/**/<br/> cout <"your input link structure matrix:" <Endl; // 0 1 <br/> for (I = 0; I <pagenum; I ++) {<br/> for (Int J = 0; j <pagenum; j ++) {<br/> // cout <* (linkarray + I) + J) <"/t "; // input matrix <br/> cout <linkarray [I] [J] <"/t "; // input matrix <br/>}< br/> cout <Endl; <br/>}< br/>/**/</P> <p> Delete [] linkarray; <br/> Delete [] PageRank; <br/> return 0; </P> <p>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.