---
title: "1004 C语言设置测试数据个数和测试结束标志"
author: "J2EE大鸟"
date: "2013-02-28T15:31:22Z"
tags: []
categories: ["编程语言"]
slug: "1004-c"
draft: false
lastmod: "2013-02-28T15:31:22Z"
id: 1817832
url: "https://benworld.iteye.com/blog/1817832"
---

设置测试数据个数和测试结束标志

 

![](http://dl.iteye.com/upload/attachment/0080/9752/1040a677-771b-3793-b275-1ff02e30e01c.jpg)  
 

```
int main(){
	int n,i,sum,a;
	while(scanf("%d", &n) && n!=0){
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d", &a);
			sum += a;
		}
		printf("%d\n", sum);
	}
}
```