摘要: 输入一个数,判断是不是素数 #include <iostream>#include <cmath>using namespace std;int main(){ int n,a; while(cin>>n) { a=0; if(n==2) { cout<<"is prime"<<endl; cont 阅读全文
posted @ 2017-01-11 17:24 Aftersoon_sun 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 在n×n方阵里填入1,2,...,n×n,要求填成蛇形。例如,n=4时方阵为: 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 #include <iostream>#include <cstring>#include <cstdlib>#include <cstdio 阅读全文
posted @ 2017-01-11 16:25 Aftersoon_sun 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 有n盏灯,编号为1~n。第一个人把所有灯打开,第2个人按下所有编号为2的倍数的开关(这些灯将被关掉),第3个人按下所有编号为3的倍数的开关(其中关掉的灯将被打开,开着的灯将被关闭),依次类推。一共有K个人,问最后有那些灯开着? 输入n和k,输出开着的灯的编号。看k<=n<=1000。 样例输入:7 阅读全文
posted @ 2017-01-11 11:18 Aftersoon_sun 阅读(150) 评论(0) 推荐(0) 编辑