DEV Community

thequvonc
thequvonc

Posted on

1

Yandex taxi

deyarli kopchilik 'Yandex taxi'ilovasidan foydalanadi
lekin kopincha bizda qaytim muammosi uchraydi
bugun biz shu masalani xal etamiz!

#include <iostream>
using namespace std;
int main() {

  int son;
  cin >> son;

  int qoldiq = son % 1000;

if (qoldiq < 500){
  cout << son - qoldiq;
  }
else{
  cout << son - qoldiq + 1000;
  }


  return 0;
}


Enter fullscreen mode Exit fullscreen mode

bunda int son yozib uni oqib olamiz
keyin esa aniq sonni 1000 sum deb belgilagandan song

keyin bizga qaytim degan ozgaruvchi kerak boladi
keyin sonni bolamiz 1000 ga oshanda esa bu bizning qaytimimizni qaniqlab beradi

if (qoldiq < 500){
  cout << son - qoldiq;
  }

Enter fullscreen mode Exit fullscreen mode

keyin aniqlab olamiz if ya'ni agar qaytimimiz 500 summdan kichik
bolsa uni qaytimdagi sonini anig'ini chiqarishimiz zarur

keyin cout << son deb uni 1000 sumga kopaytirib olamiz da uni javobini chiqaramiz.

@dawroun

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay