Welcome Guest.

2Answers

How to use c++ to access array elements

Asked by: Phillips 212 views IT September 9, 2018

What do you mean? What is it applied to?

#include<cstdio>       

 using namespace std;        

int n ,m,k,f[33][33];        

int main() {            

scanf("%d%d",&n,&m);            

f[1][0]=1;k=f[ 1][0];            

for(int i=1;i<=m;i++)             {                f[1][i]=f[2][i-1]+f[n][i-1];                f[n][i]=f[1][i-1]+f[n-1][i-1];                for(int j=2;j<n;j++)                f[j][i]=f[j -1][i-1]+f[j+1][i-1];                if(f[1]==k)k=i ,break;            }            printf("%d",f[1][m%k]);        }

This program is a lot of...Luogu p1057, ask for a comment

Addition: 入坑萌新轻喷qaq

2 Answers

  1. +8Votes  

    1. An int pointer wants to store data. It must point to a block of memory and then write data to memory by constantly writing to the elements of the array. Either define a variable to point the pointer to him or dynamically allocate a block of memory. If you point to a variable, why use the pointer directly with the variable. 2, the pointer just means the address of the memory   The real function is the memory, if the pointer is empty   is not in the variable.

    Routines:

    1234567891011   #include<iostream>using namespace std;int main(){int a[5],*p=a,i;for(i =0;i<5;i++)cin>>p[i];//cin>>*(p+i);for(i=0;i<5;i++)cout<a[i ]<<‘ ‘;return 0;}  

    Anthony Brown- September 9, 2018 |

  2. +4Votes  

    You have a problem with this code and can’t answer your question

    Harold Scott- September 9, 2018 |