im trying to create and algorithm in python but i created it in C++ instead as i don't know python well enough i know it's easy and i can learn it in one day or two it's just the syntax but i don't have the time to learn python right now (will do it later xd) so can you please convert it into python?
Code:
all i need to do is creating an algorithm that see integer numbers in a list lets call the list stocks or something and choose the min price without using min function and buy it on this day (just a variable called bought_on_day and print the number of the index) and same for sell but only difference is it will sell it at max price

``````#include <iostream>

using namespace std;

int main()

{

int max_profit = 0;

int n;

//input array size

cout<<"Enter the number of days : ";

cin>>n;

int arr[n];

//input all array values

for(int i=0;i<n;i++)

{cout<<"Enter the price on day "<<i+1<<": ";

cin>>arr[i];}

//logic is traverse the rightside of array from current day and update values accordingly

for(int i=0;i<n;i++)

{

for(int j=i+1;j<n;j++)

{

if(arr[j]-arr[i]>max_profit)

{max_profit=arr[j]-arr[i];

}

}

cout<<"Selling date :"<<"day "<<sellday+1<<", at the price of \$"<<arr[sellday]<<"\n";

cout<<"Maximum profit : \$"<<max_profit;

return 0;

}``````

It appears a lot of new members are not trying at all. Your code is badly formatted with extra blank lines and more bad formatting.

If I ignore this it looks like basic ask some questions, get input and so on. Why not start with a tutorial or two about these areas?

commented: but thank you for the link tho. and im trying to do it myself :D +0

As you commented, you wish to do this yourself. To that end, did you write something small that would ask the user for the number of days?

Or where are you stuck?