c++实例研究

从0开始

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  104 随笔 :: 0 文章 :: 20 评论 :: 0 Trackbacks
#include <iostream>
#include 
<cstdlib>
using namespace std;

int main()
{
    cout
<<"mod 3"<<endl;
    
for(int i=-10; i<10; i++)
        cout
<<i<<' '<<i%3<<endl;
    
    cout
<<"mod -3"<<endl;
    
for(int i=-10; i<10; i++)
        cout
<<i<<' '<<i%(-3)<<endl;
        
    system(
"PAUSE");
    
return 0;
}

结果
mod 3
-10 -1
-9 0
-8 -2
-7 -1
-6 0
-5 -2
-4 -1
-3 0
-2 -2
-1 -1
0 0
1 1
2 2
3 0
4 1
5 2
6 0
7 1
8 2
9 0
mod -3
-10 -1
-9 0
-8 -2
-7 -1
-6 0
-5 -2
-4 -1
-3 0
-2 -2
-1 -1
0 0
1 1
2 2
3 0
4 1
5 2
6 0
7 1
8 2
9 0
posted on 2010-10-23 14:43 elprup 阅读(201) 评论(0)  编辑 收藏 引用 所属分类: c++实例

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理