Sunday, March 20, 2016

Short note

delete an element from an array:

for (int i = index; i < /* length */; i++)
        {
            array[index] = array[index+1];
            array[length-1] = 0;
        }


size of an array:

#include<iostream>
using namespace std;
int main()
{
    int a[]={1,2,3,4,5,6};
    int size;
    size=sizeof a/sizeof(int);      //total size of array/size of array data type
    cout<<size;                     
    return 0;
}

another way:

int a[]= {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int asize = sizeof(a) / sizeof(a[0]); //size of the array


No comments:

Post a Comment

Speedup Android Studio

Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc...