Solution
#include<stdio.h>
int main(){
int n,a[20],i,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]>0)
sum=sum+a[i];
}
printf("sum=%d",sum);
return 0;
}
For python program visit the link given below.This blog is to help for the programmers to learn the programs and not to demotivate any people .Our intention is to make the learners to learn the code easily.
5
2 3 6 8 -1
sum=19
7
25 -1 -2 -3 -4 -5 -6
sum=25
2
2 2
1 4
2 7
2 1
1 4
2 7
11.000000000
7.333333333
2 2
1 7
2 7
3 1
1 4
2 2
3.333333333
2.000000000
5 5
equal
3 6
not equal
1
YES
2
NO
8
3
OUT
14
7
IN
2
Sum of series=4
4
Sum of series=20
soap
121
PRODUCT NAME:soap
COST:121
Macbook
150000
PRODUCT NAME:Macbook
COST:150000
C
67
Z
90
2
3
0 0 1 1 2 1
3
1 1 -1 1 -1 0
0.5
2.0
2
3
1 2 1 1 2 1
3
1 2 -1 -1 -1 0
0.0
0.5
2112
Mirror Image
1988
Not a Mirror Image
Solution
#include<stdio.h>
char s[50008];
int i,w,f,l,x,y,z,e,k,j;
int main()
{
scanf("%s",s);
//l=strlen(s);
l=0;
while(s[l]!='\0')
{
l++;
}
for(i=0;i<(l)/2-1&&s[i]==s[l-1-i];i++);
f=i;
if(i==(l)/2-1)
{
printf("Mirror Image");
}
else
{
for(i=(l)/2-1;i>=f&&s[i]==s[l-1-i];i--);
w=i;
if(w<f)
{
printf("Mirror Image");
}
else
{
i=l-1-f;
for(;w>=f&&s[i]==s[w];w--,i--);
if(w<f)
{
printf("Yes\n");
}
else
{
//cout<<"No\n w="<<w<<"f="<<f;
e=0;
for(k=l-1-f;k>=f;k--)
{
j=f;
i=k;
while(s[j]==s[i]&&j<=i)
{
j++;
i--;
}
if(i<j)
{
x=k+1;
y=l-1-f;
e=1;
//cout<<" e="<<e<<"x="<<x<<"y=<<y<<\n";
break;
}
}
if(e)
{
z=y-x+1;
z/=2;
//cout<<" z="<<z<<"x="<<x<<"y="<<y<<"\n";
for(i=0;i<z;i++)
{
if(s[x+i]!=s[x+z+i])
{
//cout<<" i="<<i<<"x="<<x<<"y="<<y<<"\n";
break;
}
}
if(i==z)
{
printf("Mirror Image");
return 0;
}
}
e=0;
for(k=f;k<=l-1-f;k++)
{
j=l-f-1;
i=k;
while(s[j]==s[i]&&i<=j)
{
j--;
i++;
}
if(i>j)
{
y=k-1;
x=f;
e=1;
//cout<<" e="<<e<<"x="<<x<<"y="<<y<<"\n";
break;
}
}
if(e)
{
z=y-x+1;
z/=2;
for(i=0;i<z;i++)
{
if(s[x+i]!=s[x+z+i])
{
break;
}
}
if(i==z)
{
printf("Mirror Image");
return 0;
}
}
printf("Not a Mirror Image");
}
}
}
return 0;
} 251298
6
90900
5
1
B
BattleShip
2
F
f
Frigate
Frigate
12 11 7
Radius=2.537 4 5
Radius=1.22Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...