Uri 1172 solution || Beecrowd 1172 – Array Replacement I solution in C , Python || Free Code Center

Uri 1172 Solution || Beecrowd 1172 – Array Replacement I solution

Question link:

Beecrowd 1172 – Array Replacement I solution in C

#include <stdio.h>

int main() {
 int X[10],i;
 for(i=0;i<10;i++){
     scanf("%d",&X[i]);
 }
 for(i=0;i<10;i++){
        if(X[i]==0||X[i]<0)
        {X[i]=1;}

 }
 for(i=0;i<10;i++){
 printf("X[%d] = %d\n",i,X[i]);
 }


    return 0;
}

Beecrowd 1172 – Array Replacement I solution in Python

def main():
    X = []
    for _ in range(10):
        X.append(int(input()))

    for i in range(10):
        if X[i] == 0 or X[i] < 0:
            X[i] = 1

    for i in range(10):
        print("X[{}] = {}".format(i, X[i]))

if __name__ == "__main__":
    main()

C programming tutorial

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck