我正在尝试调用#include <stdio.h>
#define PRIME_MASK ((1ULL << 2) | (1ULL << 3) | (1ULL << 5) | (1ULL << 7) |\
(1ULL << 11) | (1ULL << 13) | (1ULL << 17) | (1ULL << 19) | \
(1ULL << 23) | (1ULL << 29) | (1ULL << 31) | (1ULL << 37) | \
(1ULL << 41) | (1ULL << 43) | (1ULL << 47) | (1ULL << 53) | \
(1ULL << 59) | (1ULL << 61))
int isprime(unsigned long long n) {
if (n <= 63)
return (PRIME_MASK >> n) & 1;
if (n % 2 == 0)
return 0;
for (unsigned long long k = 3; k * k <= n; k += 2) {
if (n % k == 0)
return 0;
}
return 1;
}
int main(void) {
unsigned long long n, i;
int r;
for (;;) {
printf("Give me an even natural number greater than 2:\n>");
r = scanf("%llu", &n);
if (r == 1) {
if (n % 2 == 0 && n > 2)
break;
} else
if (r == EOF) { /* premature end of file */
return 1;
} else {
scanf("%*[^\n]%*c"); /* flush pending line */
}
}
#ifdef ONE_IS_PRIME
i = 1; /* start this loop at 1 if you want to assume 1 is prime */
#else
i = (n == 4) ? 2 : 3;
#endif
for (; i <= n / 2; i += 2) {
if (isprime(i) && isprime(n - i)) {
printf("%llu = %llu + %llu\n", n, i, n - i);
return 0;
}
}
printf("Goldbach was wrong!\n"
" %llu cannot be written as the sum of two primes\n", n);
return 0;
}
函数,如下所示,handleTap()
查找扩展到let result: AnyObject
的其他类中的对象
SCNScene
该函数有效,但应该突出显示位于另一个 override func viewDidLoad()
{
super.viewDidLoad()
...
// add a tap gesture recognizer
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
self.sceneView.addGestureRecognizer(tapGesture)
}
//(HANDLES A TAP BY THE USER) NOT WORKING
func handleTap(_ gestureRecognize: UIGestureRecognizer)
{
print("tap")
//retrieve the SCNView
let scnView = self.view as! SCNView
//check what nodes are tapped
let p = gestureRecognize.location(in: scnView)
let hitResults = scnView.hitTest(p, options: [:])
//check that we clicked on at least one object
if hitResults.count > 0
{
//retrieved the first clicked object
let result: AnyObject = hitResults[0]
//get its material
let material = result.node!.geometry!.firstMaterial!
//highlight it
SCNTransaction.begin()
SCNTransaction.animationDuration = 0.2
}
的节点,该节点延伸到class AppScene
SCNScene
我正在尝试找到一种方法让 class AppScene: SCNScene
{
//objects are located in here
}
函数搜索handleTap()
的子对象,因为它现在还不能正常工作。