© All Rights Reserved

0 views

© All Rights Reserved

- MATLAB Cheat Sheet2
- Tusshar Resume
- Smith_CSYS_1203_201530_m (Intro to Programming - Summer 2015 Online)
- Creating Gantt Charts in MS Excel
- VB Journal
- All Programs
- Design Document Resonous Technology
- How to Setup User Options in EPM Add-In _ SAP Blogs
- Mca Time-table June- 2013
- q4
- Computer Science
- Going+All-In+Preflop
- q Events
- My Resume
- Perl
- 123.txt
- Time and Date when saving a fillable form.pdf
- Transportation solver aggregate plan.xls
- FALLSEM2017-18_MEE1024_TH_SMV219_VL2017181007494_Reference(3)
- Tilte

You are on page 1of 3

// Find the shortest path from one grid cell to another.

//=======================================================

#include <iostream>

#include <algorithm>

const int N = 5;

void printMatrix(int arr[][N])

{

{

for(int j = 0; j < N; j++)

{

cout<<"\t"<<arr[i][j]<<" ";

}

cout<<endl;

}

}

{

for(int i = 0; i < N; i++)

{

for(int j = 0; j < N; j++)

{

if(a[i][j] != b[i][j])

return false;

}

}

return true;

}

int minNeighborCostToGo(int C[][N], int r, int c, int &mr, int &mc)

{

int minCost = C[r][c];

if(r > 0)

{

if(C[r-1][c] < minCost)

{

mr = r-1;

mc = c;

minCost = C[r-1][c];

}

}

if(c > 0)

{

if(C[r][c-1] < minCost)

{

minCost = C[r][c-1];

mr = r;

mc = c-1;

}

}

if(r < N-1)

{

if(C[r+1][c] < minCost)

{

minCost = C[r+1][c];

mr = r+1;

mc = c;

}

}

if (c < N - 1)

{

if(C[r][c+1] < minCost)

{

minCost = C[r][c+1];

mr = r;

mc = c + 1 ;

}

}

return minCost;

}

int main()

{

int startc = 0;

int startr = 0;

int goalc = N-1;

int goalr = N-2;

int C[N][N];

fill(&C[0][0], &C[N-1][N-1], 1);

C[goalr][goalc] = 0;

int obsr = 2;

int obsc = 2;

C[obsr][obsc] = 100;

int Ctemp[N][N];

while(!converged)

{

copy(&C[0][0], &C[N-1][N-1]+1,&Ctemp[0][0]);

for(int i = 0; i < N; i++)

{

for(int j = 0; j < N; j++)

{

if(i == goalr && j == goalc)

{

C[i][j] = 0;

}

if(i == obsr && j == obsc)

C[i][j] = 10;

else

C[i][j] = 1 + minNeighborCostToGo(C, i, j, mr, mc);

}

}

if(areEqualArrays(C,Ctemp))

converged = true;

printMatrix(C);

int r = startr;

int c = startc;

{

// get min neighbor cost

int minCost = minNeighborCostToGo(C,r,c, mr, mc);

r = mr;

c = mc;

cout<<"End!"<<endl;

return 0;

}

- MATLAB Cheat Sheet2Uploaded byShaukat Ali Shah
- Tusshar ResumeUploaded byTusshar Singh
- Smith_CSYS_1203_201530_m (Intro to Programming - Summer 2015 Online)Uploaded byWilliam Smith
- Creating Gantt Charts in MS ExcelUploaded byhilal.itani8993
- VB JournalUploaded bysiddhant
- All ProgramsUploaded byxperiac
- Design Document Resonous TechnologyUploaded bySreeSuresh
- How to Setup User Options in EPM Add-In _ SAP BlogsUploaded byBhalchandra Rupe
- Computer ScienceUploaded byJumaryse Marabut
- Mca Time-table June- 2013Uploaded byKumar Ravi
- Going+All-In+PreflopUploaded byPhilippe Simões Fernandes
- PerlUploaded byJan Abraham S. Quijano
- q4Uploaded byanil94867087
- q EventsUploaded byTeju Josh Josyula
- 123.txtUploaded byStephany Solís
- Transportation solver aggregate plan.xlsUploaded byGopichand Athukuri
- My ResumeUploaded byGeorge DelMonte
- Time and Date when saving a fillable form.pdfUploaded bykenthepa
- FALLSEM2017-18_MEE1024_TH_SMV219_VL2017181007494_Reference(3)Uploaded byRakib Khan
- TilteUploaded byGhulam Hussain
- Random number in ExcelUploaded bysakthiprime
- ADVANCED-SPREADSHEET-SKILLS.docxUploaded byNoel Arroyo Jr.
- How to Use the COUNTIF and SUMIF Functions in ExcelUploaded bycialee
- Team BookUploaded byMarcelo Nelson
- VB Code for GPS.txtUploaded byWahid Sholihul Fikri
- Excel SUBTOTAL FunctionUploaded byanita_sandhu729
- First and Last NamesUploaded byLidijaSpaseska
- formal report recoveredUploaded byapi-439064284
- 1 Introduction Evolution-Of-VP - CopyUploaded bysanafayaz12
- PermutariUploaded byAlex Tugui

- 1.MC OutlineUploaded byvijeta
- Oracle GoldenGate DirectorUploaded byZzSavioRzZ
- Web Solutions 17Uploaded bykhey
- ETourism Chapter 2 - Implications of the ICT Revolution for BusinUploaded byAdika Dashrieq Emmanuel Kaza
- SupChn_1Uploaded byXTN
- rf32Uploaded byLucia Sabado
- Raylectron v3 User GuideUploaded byanon_822046387
- Stochastic Processes 2Uploaded bySeham Raheel
- PTDUploaded byhorajolog
- ISPF Edit and Edit Macros [Ispedt03]Uploaded byjmcab
- 1 St Micro Blooms for QMUploaded bypradeep
- Tutorial 02 Beam.modelUploaded byShahid Toor
- ANSYS - Getting Started Tutorial - WorkbenchUploaded byptprabakaran
- ATP Criteria July 2017Uploaded bymammutbalaji
- Object-Oriented Modeling of VirtualUploaded byAndes Harahap
- Custom Fonts Working in All of Major BrowserUploaded byzanilhyder
- Lecture 2 Multivariate Data Analysis and VisualizationUploaded bydgrapov
- 9.2.1.11 Packet Tracer - Configuring Named Standard ACLs Instructions IGUploaded bycarlos
- EDI Notepad GuideUploaded byKashif Amin
- shell aspUploaded byMelissa Smith
- Chapter 1Number Systems.pptUploaded byAffelay Tho
- SerializationUploaded byVincenzo Aquafresca
- Cs 507 PaperUploaded bysufyanrahim
- lte-l16-course-flows-w-5g-mod.pptUploaded byAseem Rajpal
- Courses CSE University of DhakaUploaded byWalid- Bin-Habib
- Bm2012manual EnUploaded byRomildo Silva
- Congressman Paul Ryan LetterUploaded byfFRANKLIN INDEPENDENT FRANKLIN INDEPENDENT JOURNAL
- lnvg nlnibvuyviml;mjkbuhoi l ibyh9j0Uploaded byRoosevelito Maitre
- MM Quantity Conversion and RoundingUploaded bySilva Silva
- SYMBIAN OSUploaded byksonieca