关于玻璃幕墙的规定:不好意思,问个很垃圾的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/01 14:16:19
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
int j(int a)
{
int i,k;
for(k=2,i=2;i<=sqrt(a);i++)
if(a%i!=0) k++;
if(k==i)return(1);
}
void main ()
{
int h,a;
for(h=5;h<=100;h++){
if(j(h)==1){
cout<<setw(8)<<h;
a++;
}
if(a%5==0)cout<<'\n';
}
}
这个的结果怎么在每行中都有很大的空啊
是在行与行中间出现了很多空行啊

setw(8)表示空出8格,括号内的数字是空出的格数
按照你这个程序,每当j(h)==1时就会空出8格,
当然,在使用setw之前必须加上头文件#include <iomanip.h>
cout<<'\n'这个是换行
cout<<'\t'横向制表符,也会空出几格(3格)

C语言吧。
有空是为了读的时候清晰,计算机会自动忽略那些空格。
如果没有空格,全排列在一起,影响读和修改。

呵呵,这是什么语言啊?
语种太多了,搞混了。不知道了,^_^

It doesn't matter how many white spaces you leave, the important thing is is it working well?

改动cout<<setw(8)<<h;中的8

这是程序必要的格式,就是这样的,没有为什么