Разветвленный алгоритм, оператор условий. Pascal ABC. Дана цена за 1кг яблок, узнать цену за x кг яблок, пользователь вводит х, и вводит стоимость 1 кг яблок.
#include <iostream> #include <conio.h> #include <time.h> using namespace std;
void main() { srand(time(NULL)); setlocale(0, ""); int arr[17]; int a, b, chet=0, nechet = 0; cout << "Введите диапазон ." << endl << "Нижняя граница диапазона: "; cin >> a; cout << "Верхняя граница диапазона: "; cin >> b; cout << endl; for (int i = 0; i < 17; ++i) { arr[i] = a + rand() % (b-a+1); cout <<" "<<arr[i]; } for (int i = 0; i < 17; ++i) { if (arr[i] % 2 == 0) chet++; else nechet++; } if (chet > nechet) cout << " \n Четных больше"; else if (nechet>chet) cout << "\n Нечетных больше"; else cout << "\n Одинаковое количество четных и нечетных"; _getch(); }
komolovda
13.06.2020
Попробуй Program PascalGuru; var s:string; f,t:text; function preobr(s:string):string;var i,j,p,n,sered:integer; gl,zp,slovo:string; m:array [1..80] of string;beginzp:='!?*,.'; gl:='аоуыэяеёюи'; p:=pos(' ',s); i:=0; repeat inc(i); slovo:=copy(s,1,p-1); m[i]:=slovo; delete(s,1,p); p:=pos(' ',s); until p=0; n:=i+1; m[n]:=s; for i:=1 to n do begin s:=m[i]; if pos(s[length(s)],zp)<>0 then p:=length(s)-1 else p:=length(s); sered:=(p div 2)+1; if (not odd(p)) or (p<3) then continue; if pos(s[1],gl)=0 then continue; if pos(s[sered],gl)=0 then continue; if pos(s[p],gl)=0 then continue; s[1]:=UpCase(s[1]); s[sered]:=UpCase(s[sered]); s[p]:=UpCase(s[p]); m[i]:=s+'('+s[1]+','+s[sered]+','+s[p]+')'; end; s:=''; for i:=1 to n do s:=s+m[i]+' '; preobr:=s;end; beginassign(f,'input.txt'); reset(f);assign(t,'output.txt'); rewrite(t); while not eof(f) do begin readln(f,s); writeln(t, preobr(s) ); end; writeln('Файл успешно записан...'); close(f);close(t);readln;end.
Ответить на вопрос
Поделитесь своими знаниями, ответьте на вопрос:
Разветвленный алгоритм, оператор условий. Pascal ABC. Дана цена за 1кг яблок, узнать цену за x кг яблок, пользователь вводит х, и вводит стоимость 1 кг яблок.
var
price,num: real;
begin
write('Введите стоимость за 1 кг яблок: ');
readln(price);
write('Введите массу яблок: ');
readln(num);
writeln('Цена яблок ',num*price);
end.