isPalindrome 함수를 사용하려면 프로그램을 다시 작성해야합니다. 그것은 5 자리 정수를 입력하고 부울을 반환해야합니다 (회귀 식이면 true이고, 그렇지 않으면 false). cout 문을 포함 할 수 없습니다. 나는이 기능을 cout 기능없이 어떻게 할 것인지 잘 모르겠습니다.Palindrome Function
#include <iostream>
using namespace std;
int main()
{
int number, digit1, digit2, digit3, digit4, digit5;
cout << "\nEnter a 5-digit integer: ";
cin >> number;
//Break down input number into individual digits:
digit1 = number/10000;
digit2 = number % 10000/1000;
digit3 = number % 10000/100;
digit4 = number % 10000/10;
digit5 = number % 10;
if (digit1 == digit5 && digit2 == digit4)
cout << number <<" is a palindrome.\n";
else
cout << number << " is not a palindrome.\n";
return 0;
}
int isPalindrome()
{
}
힌트 :'isPalindrome' 귀하의 요구 사항에 따라'bool' 반환 형식이 있어야합니다. 함수에서'cout' 대신'return '문을 써야합니다. – Mahesh
'isPalindrome'도 입력 매개 변수가 필요합니다. 데이터를 입력해야합니다. –
나는 그것을 다시 작성하는 방법에 분실, 내가 main 함수를 유지하고 그냥 ispalindrome에 부울 있나요? – user2085224