Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- i=0
- psps=0
- pspl=0
- plpl=0
- plps=0
- j=1
- jmax=`cat $1 | tr -d ' ' | wc -w`
- while [ $j -le $jmax ]
- do
- i=1
- imax=`head -n$j $1 | tail -n1 | wc -w`
- while [ $i -le $imax ]
- do
- szam=`head -n$j $1 | tail -n1 | tr -s ' ' | cut -f$i -d' '`
- szam=$((szam % 2))
- if [ $szam -eq 0 ] && [ `expr $j % 2` -eq 0 ]
- then
- szam=`head -n$j $1 | tail -n1 | tr -s ' ' | cut -f$i -d' '`
- psps=`expr $psps + $szam`
- elif [ $szam -eq 1 ] && [ `expr $j % 2` -eq 1 ]
- then
- szam=`head -n$j $1 | tail -n1 | tr -s ' ' | cut -f$i -d' '`
- plpl=`expr $plpl + $szam`
- elif [ $szam -eq 0 ] && [ `expr $j % 2` -eq 1 ]
- then
- szam=`head -n$j $1 | tail -n1 | tr -s ' ' | cut -f$i -d' '`
- plps=`expr $plps + $szam`
- elif [ $szam -eq 1 ] && [ `expr $j % 2` -eq 0 ]
- then
- szam=`head -n$j $1 | tail -n1 | tr -s ' ' | cut -f$i -d' '`
- pspl=`expr $pspl + $szam`
- fi
- i=`expr $i + 1`
- done
- j=`expr $j + 1`
- done
- echo "Páros sorok páros számok összege: $psps"
- echo "Páros sorok páratlan számok összege: $pspl"
- echo "Páratlan sorok páros számok összege: $plps"
- echo "Páratlan sorok páratlan számok összeg: $plpl"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement