hi i am newbie here, i am not trying to ask for the answer here...
i am just asking for opinion
can someone let me know what should i include in this type of question please.
http://acm.uva.es/p/v5/524.html
hi i am newbie here, i am not trying to ask for the answer here...
i am just asking for opinion
can someone let me know what should i include in this type of question please.
http://acm.uva.es/p/v5/524.html
I'm not sure I understand the question....? Could you explain more clearly?
But, if you're wondering how you find primes...
That should work if I got my logic right.Code:#include <windows.h> #include <iostream> #include <math.h> using namespace std; BOOL IsPrime(int n); int main() { IsPrime(13); } BOOL IsPrime(int n) { int i; BOOL prime; cout << "Enter number to prime-test"; cin >> n; for(i = 2; i <= sqrt((double) n); i++) if(n % 1 == 0) is_prime = false; }
Code:Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)
please visit this website for understanding http://acm.uva.es/p/v5/524.html
thank you
please make it simple as i am the newbie of C++..
> can someone let me know what should i include in this type of question please.
Blackroot has already given you an answer - a function to check whether a given number is prime or not is a good start.
I suppose other functions would be to
- check a whole ring for being prime, as discussed in the assignment
- generate all possible rings according to some input
- get and validate some input from the user.
This code is wrong! You should not divide by 1 -> (n%1)!!!!Originally Posted by Blackroot
here u have more efficient one
u can check a number if it is prime by calling function with a argument that could by any number within int range!Code:BOOL IsPrime(int n) { if (n<=2) return true; if (n%2 == 0) return false; for(i = 3; i <= sqrt((double) n); i+=2){ if(n % i == 0){ return false; } } return true; }
i am sorry guyz.. i still dont understand ...
well can someone give example, such as i
INPUT: 4
and the OUTPUT which i done it by myself (1,2,3,4 and 1,4,3,2)
correct me if i am wrong..
can someone guide me to the process please.
can some one tell me how can i modify this code so that i can ask the user input from 1-16....
Code:int ring[16]; int m; int main() { int i, j, k; // insert the 1 value into first position which is ring[0] ring[0] = 1; while (scanf("%d", &m)) { if (m == 0) break; // printf("Get %d\n", m); if (FindNumber(1) == true) { for(j=0; j<m; j++) { printf("%d ", ring[j]); } printf("\n"); } }// end while. system("pause"); return 0; }