В
Все
М
Математика
А
Английский язык
Х
Химия
Э
Экономика
П
Право
И
Информатика
У
Українська мова
Қ
Қазақ тiлi
О
ОБЖ
Н
Немецкий язык
Б
Беларуская мова
У
Українська література
М
Музыка
П
Психология
А
Алгебра
Л
Литература
Б
Биология
М
МХК
О
Окружающий мир
О
Обществознание
И
История
Г
Геометрия
Ф
Французский язык
Ф
Физика
Д
Другие предметы
Р
Русский язык
Г
География
imaria1
imaria1
24.01.2023 05:41 •  Информатика

Напишите программу, которая циклически сдвигает элементы массива вправо (например, если элементы нумеруются, начиная с нуля, то 0-й элемент становится 1-м, 1-й становится 2-м, последний становится 0-м, то есть массив {3, 5, 7, 9} превращается в массив {9, 3, 5, 7}). входные данные сначала задано число n — количество элементов в массиве (1n35). далее через пробел записаны n чисел — элементы массива. массив состоит из целых чисел. на c# .у кого есть ответы всех

Показать ответ
Ответ:
ЕvilСookie
ЕvilСookie
22.12.2022 02:10
1.
var
  s: string;
  i, count: integer;
begin
  writeln('Vvedite stroky: ');
  readln(s);
  for i := 1 to length(s) - 2 do
    if copy(s, i, 3) = 'abc' then
      count := count + 1;
  writeln('Kol-vo: ', count);
end.
2.
var
  s1, s2: string;
  i, len1, len2: integer;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  len1 := length(s1);
  len2 := length(s2);
  if len1 > len2 then writeln('1 stroka dlinnee')
  else if len1 < len2 then writeln('2 stroka dlinnee')
  else writeln('dlini strok ravnie')
end.
3.
var
  s1, s2, s3: string;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  s3 := s1[1] + s1[2] + s2[1] + s2[2];
  writeln('Novaja stroka: ', s3);
end.
0,0(0 оценок)
Ответ:
robiya86
robiya86
30.10.2022 03:43
Romanf romanf отличник 2013-01-10t16: 13: 22+00: 00 1. подумать над алгоритмом 2. вот сам алгоритм: а. спросить у пользователя значения б. расчитать ответ в. выдать ответ на экран 3. написать код в паскале 4. исправить ошибки компиляции 5. протестировать, вводить разные числа 6. обнаружила, что если вводить числа наугад ответ получается отрицательным иногда 7. вставить код проверки введенных пользователем значений 8. убрать ошибки компиляции 9. протестировать 10. готово а вот и сама программа: program aerobus; uses crt; const totalplace = 160; var businessplaces, economyplaces: integer; businessprice, economyprice: real; totalcharge: real; a,b: integer; correctinput: boolean; begin clrscr; businessplaces: =totalplace div 4; economyplaces: = totalplace - businessplaces; writeln('business places count: ', businessplaces); writeln('economy places count: ', economyplaces); correctinput: =false; while not correctinput do begin write('please input business class ticket price: '); readln(businessprice); if(businessprice> 0) then begin correctinput: =true; end else begin writeln('the price should be a positive number, please try again'); end; end; economyprice: =businessprice/2; writeln('economy ticket price is: ', economyprice: 0: 2); correctinput: =false; while not correctinput do begin write('how many business tickets are left? : '); readln(a); if(a> =0) and (a< =businessplaces)then correctinput: =true; if(a< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(a> businessplaces) then begin writeln('please input a number which is less or equal to the tolal business place count, please try again'); end; end; correctinput: =false; while not correctinput do begin write('how many economy tickets are left? : '); readln(b); if(b> =0) and (b< =economyplaces)then correctinput: =true; if(b< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(b> economyplaces) then begin writeln('please input a number which is less or equal to the tolal economy place count, please try again'); end; end; totalcharge: =(businessplaces-a)*businessprice; totalcharge: =totalcharge+(economyplaces-b)*economyprice; writeln('the total charge is: ', totalcharge: 0: 2); writeln; writeln('press enter to exit'); readln; end.
0,0(0 оценок)
Популярные вопросы: Информатика
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота