natalyazx151092814
?>

Известны данные о площади n стран (в млн кв. км) и численности населения (в млн жителей Выведите номера тех стран, плотность населения которых больше x. Pascal

Информатика

Ответы

zodgener
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.
Pogosyan Nataliya
// F#
[<EntryPoint>]
let main argv =
    let getRandomCollection n =
        let rand = new System.Random()
        Array.map (fun x -> rand.Next(-10, 10)) [| 1..n |]
    let inputArray = getRandomCollection 15
    printf "source array: %A\n" (inputArray |> Array.toList)
    // First part
    printf "numberToCheckOnEqual: "
    let numberToCheckOnEqual = System.Console.ReadLine() |> System.Int32.Parse
    let indecesEqualsToNumber =
        inputArray
        |> Array.mapi (fun i x -> (x, i))
        |> Array.filter (fun (x, i) -> x = numberToCheckOnEqual)
        |> Array.map (fun (x, i) -> i)
        |> Array.toList
    printf "%d equals to %d: %A\n" (indecesEqualsToNumber |> List.length) numberToCheckOnEqual indecesEqualsToNumber
    // Second part
    printf "a: "
    let a = System.Console.ReadLine() |> System.Int32.Parse
    printf "b: "
    let b = System.Console.ReadLine() |> System.Int32.Parse
    let sum =
        inputArray.[a..b]
        |> Array.sum
    printf "sum of array [%d..%d]: %d\n" a b sum
    // Last part
    let finalArray =
        inputArray
        |> Array.map (fun x -> if x < 0 then x*x else x)
    printf "final array: %A" finalArray
    System.Console.ReadKey true |> ignore
    0

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Известны данные о площади n стран (в млн кв. км) и численности населения (в млн жителей Выведите номера тех стран, плотность населения которых больше x. Pascal
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

marinamarinazmeeva2444
РостиславовичЮлия1147
ИП-Сысоев1628
dmitzu8594
gav973
Dmitrievna Lvovich
Aleksei1463
Девяткина_Арсений
egorov
Mydariamiro
elenak26038778
iamhrusha
Коновалова
bagramyansvetlana
tabacoffee