Var str: string; i, count: integer;begin write('Your string: '); readln(str); i := length(str); if i > 0 then begin count := 1; while i > 0 do begin if str[i] = ' ' then count := count + 1; i := i - 1; end; end else count := 0; delete(str,3,1); writeln('Number of words: ', count); writeln(str);readln;end.
Пимкина Сергеевич
12.03.2023
Шаг №1 S = 42 - 5 = 37 n = 1 + 3 = 4 Шаг №2 S = 37 - 5 = 32 n = 4 + 3 = 7 Шаг №3 S = 32 - 5 = 27 n = 7 + 3 = 10 Шаг №4 S = 27 - 5 = 22 n = 10 + 3 = 13 Шаг №5 S = 22 - 5 = 17 n = 13 + 3 = 16 Шаг №6 S = 17 - 5 = 12 n = 16 + 3 = 19 Шаг №7 S = 12 - 5 = 7 n = 19 + 3 = 21 Шаг №8 S = 7 - 5 = 2 n = 21 + 3 = 24
А вот КОРОТКОЕ решение: 42 / 5 = 8 + 2/5 n = 8*3 = 24
Ответить на вопрос
Поделитесь своими знаниями, ответьте на вопрос:
МНОГО Заданий одновимірний масив А[10] Знайти найменший по модулю елемент масиву Мова програмування c++ або c++ Builder
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int A[10]={10, 8,-3, 5, 7,6, 6, 8,-20, 5};
int min=abs(A[0]);
int i;
for (i=0;i<9;i++){
if (abs(A[i+1])<min){
min=abs(A[i+1]);
}
}
cout<<min;
return 0;
}