讨论一下,代码以那种方式给出?

2 views
Skip to first unread message

小山

unread,
Sep 3, 2006, 11:10:31 AM9/3/06
to ju_...@googlegroups.com
一种是像这样完全贴出来:

//题目:HEU OJ 1040
//时间:2006/09/03
//参与:牛晋 赵欣苹 秦海龙

#include <stdio.h>
#include <stdlib.h>

int out_of(int,int);

int main()
{
    int n,k,result;
   
    while(scanf("%d%d",&n,&k) != EOF){
    if(n==0 && k==0) break;
    if(k>n/2)  k = n-k;
    if(k == 0) {
        printf("1\n");
        continue;
    }
    if(k == 1) {
            printf("%d\n",n);
        continue;
    }
       
    result=out_of(n, k);

        printf("%d\n",result);
       
    }

   return 0;
}

int out_of(int n, int k)
{
    int  n_tmp = n+1-k;
    long long result = 1;

    for(int k_tmp = 1; k_tmp <= k; k_tmp++){
        result *= n_tmp;
    //if(result % k_tmp != 0)  printf(" Error ");
    result /= k_tmp;
    ++n_tmp;
    }
   
    return  result;
}

因为google group的帖子只能是纯文本格式所以代码可能会十分不美观。

--
Discover the design of nature, discover the evidence of God.

小山

unread,
Sep 3, 2006, 11:17:15 AM9/3/06
to ju_...@googlegroups.com
第二是像这样,完整代码代码只以附件形式给出,帖子里只能出现少量的代码片段:

copy(  coll.begin(), coll.end(),  // Source
          coll.end())                    // Destination

大家觉得那个比较合适,我们定个论坛的规范。
1040.cpp
Reply all
Reply to author
Forward
0 new messages