请帮我为下面的问题写C ++代码 [英] please help me write c++ code for this problem below
本文介绍了请帮我为下面的问题写C ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个计算素数小于给定自然数的程序.
解决方案
哇,它看起来是个新问题,我想它还没有."从来没有人遇到过,因此您无法在 ^ ].
#include<iostream.h> #include<conio.h> void main() { clrscr(); int n; cin>>n; for(i=2;i<=n/2;i++) { if(n%i==0) { cout<<"the no. is not prime"; break; } } if(i>n/2) { cout<<"no. is prime"; } getch(); }
转到此处 [ 解决方案
Wow, it looks a fresh problem, I suppose it hasn''t ever faced by nobody, hence you can''t find anything on Google about it[^].
#include<iostream.h> #include<conio.h> void main() { clrscr(); int n; cin>>n; for(i=2;i<=n/2;i++) { if(n%i==0) { cout<<"the no. is not prime"; break; } } if(i>n/2) { cout<<"no. is prime"; } getch(); }
Go here [^]
这篇关于请帮我为下面的问题写C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文