Click here to Skip to main content
14,634,917 members
Rate this:
Please Sign up or sign in to vote.
See more:
is anyone help me to convert a python code into c++???

What I have tried:

n = int(input())
a = list(map(int,input().split()))
max_num = 0
min_num = 100001
arr_sum = 0
for i in a:
    max_num = max(max_num, i)
    min_num = min(min_num, i)
    arr_sum += i
print(arr_sum-max_num, arr_sum-min_num)
Updated 16-Jul-20 20:53pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Step 1: Learn Python.
Step 2: Learn C++.
Step 3: Use the Python code as a specification for a new C++ app.

Never convert languages, it doesn't produce good code in the target language because it uses a totally different framework, and the data structures that make something work well in the source language are normally very different in the target language.

And to be honest, if you can't write trivial code like that for yourself in C++, then you are going to fail your course anyway...

Oh, and by the way ... you do realise that most teachers are aware of sites like this and will recognise when you didn;t produce your own code? Just a thought.
web phuppo 18-Jul-20 5:31am
to na ya website q bane ha phr kutta
OriginalGriff 18-Jul-20 6:00am
Sorry, you are going to have to use English - I have no idea what you are saying, and Google Translate doesn't help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100