文章

49

粉丝

90

获赞

90

访问

37.9k

头像
C++
P1355 哈尔滨工业大学机试
发布于2024年3月18日 10:52
阅读数 606

  1. #include<cmath>
  2. #include<iostream>
  3. using namespace std;
  4. bool sushu(int n)
  5. {
  6. if (n < 2)
  7. {
  8. return false;
  9. }
  10. else
  11. {
  12. for (int i = 2; i <= sqrt(n); i++)
  13. {
  14. if (n % i == 0)
  15. return false;
  16. }
  17. }
  18. return true;
  19. }
  20. int main()
  21. {
  22. int n;
  23. while (cin >> n)
  24. {
  25. if (sushu(n))
  26. {
  27. cout << "yes" << endl;
  28. }
  29. else
  30. {
  31. cout << "no" << endl;
  32. }
  33. }
  34. return 0;
  35. }

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发