Комментарии:
hy bro will it pass all the test cases on mettl or not can u please tell me
Ответитьgive me the source code asap plz .
ОтветитьI want this in java
ОтветитьFor those who want this code in java..
import java.lang.Math;
class ChargeFind{
public static void main(String args[])
{
char p = 'P',b='N';
String s="NP";
int a[] = {1,2,2}, i;
int sum=a[0];
for(i=0; i<s.length(); i++)
{
if(s.charAt(i) == p)
{
sum = sum + a[i+1];
}
else
{
sum = sum - a[i+1];
}
//sum =sum - a[i+1];
}
sum = Math.abs(sum);
System.out.println(sum*100);
}
}