Why getting error in bash for loop?

后端 未结 2 907
我在风中等你
我在风中等你 2021-01-17 06:51

I am trying to run the below code using for loop but i am getting syntax error. Please help.

Input Format: The first line of the input contains an i

2条回答
  •  暖寄归人
    2021-01-17 07:04

    This will work. However you should insert some helper messages inside:

    #!/bin/bash
    
    read n
    sum=0
    
    for (( i=1; i<=n; i++ ))
    do
            read val
            ((sum^=val))
    done
    echo $sum
    

提交回复
热议问题