---
title: "1003  C语言输入以某个特殊输入为结束标志"
author: "J2EE大鸟"
date: "2013-02-28T14:46:48Z"
tags: []
categories: ["编程语言"]
slug: "1003-c"
draft: false
lastmod: "2013-02-28T14:46:48Z"
id: 1817791
url: "https://benworld.iteye.com/blog/1817791"
---

输入不说明有多少个Input Block,但以某个特殊输入为结束标志。

 

![](http://dl.iteye.com/upload/attachment/0080/9714/6fc316a0-5a32-3d70-8c4c-7143acf6b094.jpg)  
 

```
C语法：
	while(scanf("%d",&n)  && n!=0 ) 
	{     .... } 

C++语法：
	while( cin >> n && n != 0 ) {     .... } 
```

 

```
#include <stdio.h>

int main(){
	int a,b;
	while(scanf("%d %d", &a, &b) && (a!=0 || b!=0)){
		printf("%d\n", a+b);
	}
}
```