1628.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 38 行

CPP
38
字号
/*  This Code is Submitted by wywcgs for Problem 1628 on 2005-03-23 at 18:01:31 */ 
#include <stdio.h>

int main()
{
    int N, guest[31];
    int i, temp, total;
    
    while(scanf("%d", &N) == 1){
        if(N == 0){
            return 0;
        }else{
            total = 0;
            temp = 0;
            for(i = 0; i < N; i++){
                scanf("%d", &guest[i]);
                total += guest[i];
            }
            if(total % 2 == 1){
                printf("No equal partitioning.\n");
            }else{
                total /= 2;
                for(i = 0; i < N; i++){
                    temp += guest[i];
                    if(temp == total){
                        printf("Sam stops at position %d and Ella stops at position %d.\n", (i+1), (i+2));
                        break;
                    }else if(temp > total){
                        printf("No equal partitioning.\n");
                        break;
                    }
                }
            }
        }
    }
    
    return 0;
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?