Write a C++ program to check if two or more non-negative given integers have the same rightmost digit

  • برمجة سي بلس بلس
  • برمجة

Write a C++ program to check if two or more non-negative given integers have the same rightmost digit

Sample Output:

1 
1 
0

الأجوبة

#include <iostream>

using namespace std;

bool test(int x, int y, int z)
        {
           return x % 10 == y % 10 || x % 10 == z % 10 || y % 10 == z % 10;
        }
        
        
int main() 
 {
  cout << test(11, 21, 31) << endl; 
  cout << test(11, 22, 31) << endl; 
  cout << test(11, 22, 33) << endl; 
  return 0;      
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...