#include
using namespace std;
int withdraw;
double acc_amnt;
int main()
{
// your code goes here.
cin>>withdraw>>acc_amnt;
// If the Transaction SUCCESS.
if((withdraw%5 == 0) && (acc_amnt > (withdraw+0.50)))
{
acc_amnt = acc_amnt - (withdraw+0.500);
//cout<<acc_num;
printf("%.2f \n",acc_amnt);
}
// If the Transaction not SUCCESS.
if(withdraw%5 != 0 || acc_amnt < withdraw)
{
//cout<<acc_num;
printf("%.2f \n",acc_amnt);
}
return 0;
}
import java.util.Scanner;
class code_chef_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double balance=120.0;
System.out.println(“Enter the amount to be withdrawn :”);
double withdrawal=sc.nextDouble();
if(((withdrawal+0.5)<=balance) && (withdrawal % 5 == 0))//successful transaction.
{
balance= balance-(withdrawal+0.5);
System.out.println(balance);
}
else if(((withdrawal+0.5)>balance) && (withdrawal % 5 == 0)) //insufficient funds.
System.out.println(balance);
else // incorrect withdrawal amount.
System.out.println(balance);
}
}
LINK : CodeChef: Practical coding for everyone
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
cin.ignore();
while (n–)
{int c=0;
string str, strj;
getline(cin, str);
getline(cin, strj);
{for(int i=0; i<str.length(); i++)
{ for(int j=0; j<strj.length(); j++)
if(str[i]==strj[j])
{ c++;
strj[j]='1';
break; }}
cout<<c<<endl;
}
}
}
I am getting correct answers in my IDE and even in codechef one but when i try to submit it, it says wrong answer. Can anyone tell me the mistake which i commited?
@jha_suryash99
try this input :
1
a
aaa
output should be:3
Question was “You have to find out how many characters of S are in J as well.”…I think u are doing it other way around.
#include
#include<math.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n,d,h;
cin>>n>>d>>h;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int tot=0;
for(int i=0;i<n;i++)
{
if(a[i]>0)
{
tot+=a[i];
}
else
{
tot=max(tot-d,0);
}
}
if(tot>h)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
this is my code for ‘REDALERT’ from July lunch time i am getting W A
please help me o resolve this issue.
t = int(input())
for i in range(t):
A,B = input().split()
if(A>B):
print(">")
elif(A<B):
print("<")
else:
print("=")
It is showing wrong answer. Why is it so?
justhrk
February 2, 2022, 3:28am
151
#include
using namespace std;
int main()
{
int n,r=0;
cin>>n;
while(n!=0)
{
r=(r*10)+(n%10);
n/=10;
}
cout<<r<<endl;
return 0;
}