Jump to content

Conversão Codigo C para Python


Recommended Posts

Estou com dificuldade para converter este script em C para Python. Alguém me ajuda por favor

int main() {
    int i, j;
    int n;
    int soma=0;
    int a, b;
    int pilha[PMAX];
    int moves=0;
    int movimentos=0;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &pilha[ i ]);
        soma+=pilha[ i ];


    for (i=0; i<n; i++) {
        moves+=(pilha[ i ]-(i+a));
        if (pilha[ i ]>i+a) {
            movimentos+=(pilha[ i ]-(i+a));

    if (moves!=0) {
    } else {
        printf("%d\n", movimentos);

    return 0;
Edited by pwseo
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.