Ilk qadam :: Yechimlar
Masala A
Kiritilgan ikkita sonni qo‘shadigan dastur tuzing.
Har bir qatorda \(-10^4\) dan \(10^4\) gacha bo‘lgan sonlar
Berilgan ikkita son yig‘indisi
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a + b);
return 0;
}
import math
import itboom
def main():
a = int(input())
b = int(input())
print(a + b)
if __name__ == '__main__':
main()
Masala B
Kiritilgan birinchi sonning ikkinchi songa bo‘lgandagi qoldig‘ini hisoblaydigan dastur tuzing.
Har bir qatorda \(-10^4\) dan \(10^4\) gacha bo‘lgan ikkita son.
Birinchi sonni ikkinchi songa bo‘lgandagi qoldiq qiymati
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a % b);
return 0;
}
import math
def main():
a = int(input())
b = int(input())
print(int(math.fmod(a, b)))
if __name__ == '__main__':
main()
Masala C
Kiritilgan ikkita sondan eng kattasini ekranga chiqaradigan dastur tuzing.
Har bir qatorda \(-10^4\) dan \(10^4\) gacha bo‘lgan ikkita son.
Kiritilgan ikkita sondan eng kattasi
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
if (a > b) {
printf("%d", a);
} else {
printf("%d", b);
}
return 0;
}
import math
def main():
print(max(int(input()), int(input())))
if __name__ == '__main__':
main()
Masala D
0 dan boshlab kiritilgan songacha bo‘lgan sonlarni qatorma-qator ekranga chiqaradigan dastur tuzing.
1 dan 100 gacha bo‘lgan son
Masala shartidagi sonlar
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
printf("%d\n", i);
}
return 0;
}
import math
import itboom
def main():
n = int(input())
for i in range(n):
print(i)
if __name__ == '__main__':
main()
Masala E
Ochig’i yechimni o’zim qilmadim, internetdan olib qo’ya qoldim.
Brainfuck dasturlash tilidan foydalanib itboom
so‘zini ekranga chiqaradigan dastur tuzing.
+[----->+++<]>++.+++++++++++.++[->+++<]>.+++++++++++++..--.