计数程序 [英] counting program

查看:69
本文介绍了计数程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是一个小孩,我用C ++编程,本周开始了解基本的输入输出,控制结构,等等等等。


我想制作一个永远计数的程序,并提取素数,将它们发送到指定的.txt文件。


任何人都可以帮助我吗?

Hi, Im just a kid and I program in C++, and I started this week and know about basic input ouput, control structures, blah blah blah.

I wanted to make a program that keeps counting forever, and pulls out prime numbers, sending them to a specified .txt file.

Could anyone help me?

推荐答案

当然,我首先要决定程序如何识别素数。如果你可以将它写入一个函数,你可以在每次点击你想要的数字时调用它。之后,程序的其余部分只是一个递增计数的无限循环,然后调用该检查。
Sure, I would start by deciding on how the program will identify a prime number. If you can write that into a function, you can call it every time you hit a number you want. After that, the rest of the program is just an infinite loop that increments a count, and then calls that check.


谢谢sicarie。

你能给我一个关于素数方法的概念吗?

我用visual studio express C ++ 2005
thanks sicarie.
could you give me an idea of the prime number method?
I use visual studio express C++ 2005



感谢sicarie。

你能给我一个关于素数方法的概念吗?

我使用visual studio express C ++ 2005
thanks sicarie.
could you give me an idea of the prime number method?
I use visual studio express C++ 2005



我想你可以通过使用模数(%)运算符来强制它,并检查所有数字2-9。而且,显然,你不需要在两个以外的任何偶数上进行。

I would imagine that you could brute force it by using the modulus ( % ) operator, and checking all the numbers 2-9. And, obviously, you don''t need to do it on any even number outside of two.


这篇关于计数程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆