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.
1
x = int(input())
if(x >= 100 and x <= 999):
print("Число трехзначное")
else: print("Число НЕ трехзначное")
2
month = int(input())
if(month >= 1 and month <= 12):
if(month == 1 or month == 3 or month == 5 or month == 7 or month == 8
or month == 10 or month == 12):
print(31)
elif(month == 2):
print(28)
else: print(30)
else: print("Неверно введеный номер месяца!")
3
from sys import exit
month = int(input("Месяц: "))
day = int(input("День: "))
remainder = 0
if(month >= 1 and month <= 12):
if(month == 1 or month == 3 or month == 5 or
month == 7 or month == 8 or month == 10 or month == 12):
if(day >= 1 and day <= 31):
pass
else: print("Неверно введены дни месяца!"); exit();
elif(month == 2):
if(day >= 1 and day <= 28):
pass
else: print("Неверно введены дни месяца!"); exit();
else:
if(day >= 1 and day <= 30):
pass
else:
print("Неверно введены дни месяца!"); exit();
for i in range(1, month+1):
if(i == 1 or i == 3 or i == 5 or i == 7 or i == 8
or i == 10 or i == 12):
remainder += 31
elif(i == 2):
remainder += 28
else: remainder += 30
remainder += day
print("До нового года осталось: " + str(365 - remainder))
else: print("Неверно введеный номер месяца!")
4
month = int(input())
if(month >= 1 and month <= 12):
if(month == 12 or month == 1 or month == 2):
print("Winter!")
elif(month == 3 or month == 4 or month == 5):
print("Spring!")
elif(month == 6 or month == 7 or month == 8):
print("Summer!")
elif(month == 9 or month == 10 or month == 11):
print("Autumn!")
else: print("Wrong number of month!")