View Code of Problem 92

using namespace std;
int issu(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0) {
			return 0;
		}
	}
	return 1;
}
int ishui(int n) {
	int x = 0;
	int m = n;
	while (n) {
		x =x*10+ n % 10;
		n = n / 10;
	}
	if (m == x) {
		return 1;
	}
	else return 0;
}
int main()
{
	int m, n;
	cin >> m >> n;
	int k = 0;
	for (int i = m; i <= n; i++) {
		if (issu(i) && ishui(i)) {
			cout << setw(6) << i;
			k++;
			if (k == 5) {
				cout << endl;
				k = 0;
			}
		}
	}
}
/*
Main.cc: In function 'int issu(int)':
Main.cc:3:23: error: 'sqrt' was not declared in this scope
  for (int i = 2; i <= sqrt(n); i++) {
                       ^~~~
Main.cc:3:23: note: suggested alternative: 'short'
  for (int i = 2; i <= sqrt(n); i++) {
                       ^~~~
                       short
Main.cc: In function 'int main()':
Main.cc:25:2: error: 'cin' was not declared in this scope
  cin >> m >> n;
  ^~~
Main.cc:25:2: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cc:1:1:
+#include <iostream>
 using namespace std;
Main.cc:25:2:
  cin >> m >> n;
  ^~~
Main.cc:29:4: error: 'cout' was not declared in this scope
    cout << setw(6) << i;
    ^~~~
Main.cc:29:4: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
Main.cc:29:12: error: 'setw' was not declared in this scope
    cout << setw(6) << i;
            ^~~~
Main.cc:29:12: note: suggested alternative: 'std'
    cout << setw(6) << i;
            ^~~~
            std
Main.cc:32:13: error: 'endl' was not declared in this scope
     cout << endl;
             ^~~~
Main.cc:32:13: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
Main.cc:1:1:
+#include <ostream>
 using namespace std;
Main.cc:32:13:
     cout << endl;
             ^~~~
*/

Double click to view unformatted code.


Back to problem 92