B What would the register contain if only motor C was ON and the motors were turning in a BACKWARDS direction?
c What would the register contain if motor B and motor C were both ON but
B was turning in a backward direction and C was turning in a forward
direction?
d What would be the effect if the register contained the following?
1 1 1 1 1 1 1 1
public static void main(String args[]){
java.util.Scanner in = new java.util.Scanner(System.in);
String string = in.nextLine(); char chars[] = new char[4];
chars[0] = in.nextLine().charAt(0); chars[2] = in.nextLine().charAt(0);
for(int sChar = 0; sChar<string.length(); sChar++)
if(string.charAt(sChar)==chars[0])chars[1]++;
else if(string.charAt(sChar)==chars[2])chars[3]++;
System.out.print("\n"+(chars[1]==chars[3]?chars[0]+""+chars[2]:chars[1]>chars[3]?chars[0]:chars[2]));
}
}
var
a: array[1..l] of integer;
d: array[1..l] of real;
i, otr, k, m: integer;
begin
otr:=0; k:=0; m:=0;
//считаем массив а
for i:=1 to l do
begin
readln(a[i]);
//если ввели положительное число,увеличим перем. otr на 1
if a[i] < 0 then
inc(otr);
//если ввели отрицательное число,увеличим перем. k на 1
//и к переменной m прибавим элемент
if a[i] > 0 then
begin
inc(k);
inc(m, a[i]);
end;
end;
//заполним массив d
for i:=1 to l do
//если индекс четный, присвоим элементу otr
//иначе присвоим среднее арифметическое
if i mod 2 = 0 then
d[i] := otr
else
d[i] := m/k;
end.