Forwarded from Vaibhav Choubey
Vaibhav Choubey
Photo
Code is in java
Send me "candles " full question
@mradal_777
@mradal_777
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*Birthday Cake Candles Code in C*/
int main() {
int i;
int n;
int max = 0;
scanf("%d", & n);
int a[n];
int count = 0;
for (i = 1; i <= n; i++) {
scanf("%d", & a[i]);
if (max < a[i])
max = a[i];
}
for (i = 1; i <= n; i++)
if (a[i] == max)
count++;
printf("%d", count);
return 0;
}
Candles code in C
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*Birthday Cake Candles Code in C*/
int main() {
int i;
int n;
int max = 0;
scanf("%d", & n);
int a[n];
int count = 0;
for (i = 1; i <= n; i++) {
scanf("%d", & a[i]);
if (max < a[i])
max = a[i];
}
for (i = 1; i <= n; i++)
if (a[i] == max)
count++;
printf("%d", count);
return 0;
}
Candles code in C
int a[]=new int[N];
while(true)
{
int z=0;
for(int i=1;i<N;i++)
{
a[i]=i+1;
}
boolean b=true;
for(int i=0;i<N && i!=Integer.MAX_VALUE;i++)
{
if(b)
{
a[i]=Integer.MAX_VALUE;
b=false;
}
else
b=true;
if(a[i]!=Integer.MAX_VALUE)
z++;
}
if(z==1)
return z;
}
โ๏ธโ๏ธ
Block code
while(true)
{
int z=0;
for(int i=1;i<N;i++)
{
a[i]=i+1;
}
boolean b=true;
for(int i=0;i<N && i!=Integer.MAX_VALUE;i++)
{
if(b)
{
a[i]=Integer.MAX_VALUE;
b=false;
}
else
b=true;
if(a[i]!=Integer.MAX_VALUE)
z++;
}
if(z==1)
return z;
}
โ๏ธโ๏ธ
Block code
Forwarded from Vaibhav Choubey
Forwarded from Deleted Account
Mindtree _C1_ JD_(2021_off-campus).pdf
575.6 KB