c++ - Starting Code from 1 instead of 0? -


#include<iostream>  using namespace std; int main()  int quantity = 0; int = 0; int b = 0; int x = 0; int y = 0; int z; double region[5][6]; int shipping = 20.00; region[0][0] = 0;   (x=0;x<5;x++) {      (y=0; y<6; y++) {         z=x;        if(y == 0)        {region[x][y] = y + 1 + z;}        else if(y == 1)        {region[x][y] =  region[x][y-1] * 2;}            else if(y == 2)            {region[x][y] = region[x][y-1]  + .50;}                else if(y == 3)                    {region[x][y] = region[x][y-1] + .50;}                    else if(y == 4)                    {region[x][y] = region[x][y-1] + .250;}                        else                         {region[x][y] = region[x][y-1] + .250;}     }  } cout<<"please input region"<<endl; cin>>a; cout<<"enter quantity"<<endl; cin>>quantity; if (quantity > 6) {b = 5;} else {b = quantity;}  cout<<"the price of shipping comes out to: "<<region[a][b] + shipping<<" since $20 added shipping cost"<<endl;  return 0 ; 

}

so right have type 0,0 region , quantity first cell. since starting @ region 1 , quantity 1, make user input 1,1. how go doing c++. thanks!

after user has entered region validate values greater 0. if subtract 1 them , process data now.

if(a < 1) = 1; if(quantity < 1) quantity = 1;  // subtract 1 values a--; quantity--;  if (quantity > 6) {b = 5;} else {b = quantity;} cout<<"the price of shipping comes out to: "<<region[a][b] + shipping<<" since $20 added shipping cost"<<endl; 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -