C版本:
#include
int main(){
int numPos = 0,sumPos = 0,numNeg = 0,sumNeg = 0,in;
printf("Please key in the integers,key in 0 to stop:\n");
do{
scanf("%d",&in);
if(in > 0){
numPos++;
sumPos += in;
}
else if(in < 0){
numNeg++;
sumNeg += in;
}
}while(in != 0);
printf("There are %d positive integers,whose sum is %d.\n",numPos,sumPos);
printf("There are %d negative integers,whose sum is %d.\n",numNeg,sumNeg);
return 0;
}
borland C版本5.5编译通过.
Java版本:
import java.util.Scanner;
public class test{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int
python求n个数中负数的个数_输入n个整数 求输入正数之和 负数之和 并统计相应正数和负数的个数 以输入0表示输入结束....
如果觉得《python求n个数中负数的个数_输入n个整数 求输入正数之和 负数之和 并统计相应正数》对你有帮助,请点赞、收藏,并留下你的观点哦!