Navneetnadha
BAN USERwe can use a 2-d char. array to store strings and map to the array for each character present in the pattern string
for ex-
arr[0]- 'r' 'e' 'd' '\0' '\0'
arr[1]- 'b' 'l' 'a' 'c' 'k'
.
.
.
and in main program replace it accordingly...
#include<stdio.h>
int main()
{
int arr[30],i,j,sum,n,count=0;
printf("enter the no. of input\n");
scanf("%d",&n);
printf("enter the values\n");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
i=0;
j=n-1;
while(i<=j)
{
if(i==j)
{
count++;
break;
}
if(arr[j]==100)
{
count++;
j--;
}
else
{
sum=arr[i]+arr[j];
if(sum>100)
{
count++;
j--;
}
if(sum==100)
{
count++;
i++;
j--;
}
else{
while(sum<100)
{
i++;
sum+=arr[i];
if(sum==100)
{
count++;
i++;
j--;
break;
}
}
count++;
j--;
}
}
}
printf("minimum no. of pipes required are: %d",count);
return 0;
}
Repcassicjohnson, Android Engineer at Accenture
Hi, I work as an Painter, making art Paintings for the world’s top art galleries. When I have an ...
#include<stdio.h>
- Navneetnadha March 02, 2015#include<string.h>
int main()
{
char str[30],i=0,hash[256]={0},count_max=0;
printf("enter the string\n");
scanf("%s",str);
int count=0;
int k=strlen(str);
while(i<k)
{
while(hash[str[i]]==0&&i<k)
{
hash[str[i]]+=1;
count++;
i++;
}
if(count>count_max)
{
count_max=count;
//memset(hash,0,sizeof(hash));
}
else{
count=0;
memset(hash,0,sizeof(hash));
}
}
printf("%d",count_max);
return 0;
}