• Написати програму скорочення звичайного дробу. abc pascal

Ответы 1

  • На паскалі:program _1;var a,b,c,i:integer;beginwrite('Введіть чисельник дробу: ');readln(a);write('Введіть знаменник дробу: ');readln(b);if a>b then c:=a else c:=b;for i:=1 to c doif ((a mod i)=0) and ((b mod i)=0) thenbegina:=a div i;b:=b div i;end;writeln(a,'/',b);end.На Сішці:#include <iostream>using namespace std;int main(){ setlocale(LC_ALL, "Ukr"); int a,b,c,i; cout<<"Введіть чисельник: "<<endl; cin>>a; cout<<"Введіть знаменник: "<<endl; cin>>b; (a>b)?c=a:c=b; for (i=1;i<=c;i++){ if ((a%i==0)&&(b%i==0)){ a=a/i; b=b/i; } } cout<<a<<"/"<<b<<endl; system("pause"); }Буду вдячний за "Кращу відповідь"
    • Автор:

      calvo
    • 6 лет назад
    • 0
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years