Home
О нас
Products
Services
Регистрация
Войти
Поиск
Procrastination
@Procrastination
October 2021
1
9
Report
Программа на языке С
Написать рекурсивную функцию, определяющую, является ли заданное натуральное число простым
Please enter comments
Please enter your name.
Please enter the correct email address.
Agree to
terms of service
You must agree before submitting.
Send
Answers & Comments
Курчик
#include "stdafx.h"#include <iostream>#include <Windows.h>
using namespace std;
bool test(int, int);void main(){
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int a;
cout << "Введите натуральное число: ";
cin >> a;
if (test(a, 2))
cout << "Простое" << endl;
else
cout << "Составное" << endl;
system("pause");
}
bool test(int a, int del){
if (del < a)
if (a % del == 0)
return false;
else
test(a, del + 1);
}
2 votes
Thanks 0
Procrastination
мне нужно разбить на
Procrastination
строки для рекурсии
Procrastination
начало самой программы
Procrastination
рекурсивная и не рекурсивная часть
Procrastination
и получается на экране он будет выводить два результата с рекурсией и без
×
Report "Программа на языке С Написать рекурсивную функцию, определяющую, является ли зад..."
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
Helpful Links
О нас
Политика конфиденциальности
Правила и условия
Copyright
Контакты
Helpful Social
Get monthly updates
Submit
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include "stdafx.h"#include <iostream>#include <Windows.h>
using namespace std;
bool test(int, int);void main(){ SetConsoleCP(1251); SetConsoleOutputCP(1251);
int a;
cout << "Введите натуральное число: "; cin >> a;
if (test(a, 2)) cout << "Простое" << endl; else cout << "Составное" << endl;
system("pause");}
bool test(int a, int del){ if (del < a) if (a % del == 0) return false; else test(a, del + 1);}