From 2f443a16252333bb65305bde539ae401171df338 Mon Sep 17 00:00:00 2001 From: kanishkasrivastava Date: Thu, 21 Oct 2021 16:41:03 +0000 Subject: [PATCH 1/2] added cpp program --- Product Of Array Except Self | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Product Of Array Except Self diff --git a/Product Of Array Except Self b/Product Of Array Except Self new file mode 100644 index 00000000..abedca36 --- /dev/null +++ b/Product Of Array Except Self @@ -0,0 +1,35 @@ +/* +Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. +The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. +You must write an algorithm that runs in O(n) time and without using the division operation. +*/ + +/* +Input: nums = [1,2,3,4] +Output: [24,12,8,6] +*/ + +/* +Input: nums = [-1,1,0,-3,3] +Output: [0,0,9,0,0] +*/ + +#include +using namespace std; +int main() +{ + int a[100],b[100],n,mult=1; + cout<<"Enter the number of elements in the array: "; + cin>>n; + cout<<"Enter the elements of the array: "; + for(int i=0;i>a[i]; + mult = mult * a[i]; + } + for(int i=0;i Date: Thu, 21 Oct 2021 16:43:14 +0000 Subject: [PATCH 2/2] added cpp program --- copy.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 copy.c diff --git a/copy.c b/copy.c new file mode 100644 index 00000000..c0c34180 --- /dev/null +++ b/copy.c @@ -0,0 +1,15 @@ +#include +#include +#include +main() +{ + + char a[1000]; + printf(" ENTER A STRING\n"); + scanf("%[^\n]s",a); + char b[strlen(a)]; + strcpy(b,a); + printf("copied string: %s",b); + printf("\n %d are the number of characters copied",strlen(a)); + getch(); +}