大概思路如下: ... foreach my $rl (@tmp1){ foreach my $ex (@box){ if ($ex ne $rl ){push(@box,$rl);} }} ... 运行起来会出问题,请问有没有好的解决办法??
#! /bin/bash i=0 while read line ;do a[$i] =$line ((i++)) done <13.txt echo ${a[$i]} 调试错误信息: [babywolf@dev2 shell]$ sh -x test + i=0 + read line + 'a[0]' =ningxia 13909561289 -DSZCQQH test: line 4: a[0]: command not found + (( i++ )) + read line + 'a[1]' =qinghai 13997241272 -DSZCQQH test: line 4: a[1]: command not found + (( i++ )) + read line + 'a[2]' =gansu 13830578852 -YSYYSD ...
for i in 1 2 3 do a$i=1 echo "${a$i}" done 我想得到的结果是将a1,a2,a3都赋值为1,然后再显示出来,以上的写法有问题的,请教如何更正?
inputFile>>t; t是一个对象数组,我想用ifstream对象inputFile对t的每个对象赋值,却出现了error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class teamInf []' (or there is no acceptable conversion)这是为什么啊,应该如何给t赋值啊,假设文件中的数据是 **** ********* *********** **** ********* *********** **** ********* *********** **** ********* *********** **** *****...
我定义了一个二维字串数组 char str[3][5]。请教下,二维字串如何进行字串的修改呢?比如修改第二个字串的值,我用 str[1] = "tom" 也不行,用 str[1][] = "tom" 也不行,在g++ 3.2.2下却无法编译通过。如果用 str[1][0] = 't' 这样的形式那太麻烦了吧,有没有其它的好的方法呢?多谢!!