C语言偏程。。。偏程:1.计算1~10之间的奇数之和及偶数之和。 2.输入10个整数,分别计算输入的正数和负数之和。 真难搞。。。 扫码下载作业帮搜索答疑一搜即得 答案解析 查看更多优质解析 解答一 举报 #include void main() { int js = 0,os = 0; for (int i = 1;i 解析看不懂?免费查看同类题...
// c语言,用函数实现从键盘输入10个整数,统计非负数个数,负数个数,并计算非负数之和,负数之和,非负数之积void func() {int i = 0;int arr[10] = { 0 };int count_a = 0; // 非负整数数量int count_b = 0; // 负数数量int sum_a = 0; // 非负整数之和int sum_b = ...
int main(){ int i=0,f=0,z=0,zj=1;printf("请输入10个整数:);for(i=1;i<=10;i++){ printf("%d",&i);if(i<0)f++;else {z++;zj=zj*z;} } printf("非负数之和:%d",&z);printf("负数之和:%d",&f);printf("非负数之积:%d",&zj);return 0;} 只记得这些,好...
System.out.println("正数有"+t+"个"+",负数有"+f+"个"+",所有数的和为:"+sum);} }
include <stdio.h> int main() { int n;int odd = 0, even = 0;while ((scanf("%d", &n)) == 1) { if (n < 0)break;if (n % 2)odd += n;else even += n;} printf("sumodd=%d sumeven=%d", odd, even);return 0;} ...
include <stdio.h> void main(){ int a[20];int i, sum=0;for(i=0; i<20; i++){ scanf("%d", &a[i]); //先将输入的20个整数存储在数组a中 } for(i=0;<20; i++){ if(a[i]<0) { //如果a[i]<0,即a[i]为负数, 则打印出来 printf("%d", a[i]);} els...
代码文本:include "stdio.h"int main(int argc,char *argv[]){ int n,sumodd,sumeven;printf("Please enter some positive integer(<0 end)...\n");sumodd=sumeven=0;while(scanf("%d",&n) && n>0)n&1 ? sumodd+=n : sumeven+=n;printf("sumodd=%d sumeven=%d\n",sumodd,...
C语言-编程实现从键盘任意输入20个整数,计算其中所有非负数之和//计算20个非负整数之和#include<stdio.h>#include<string.h>int main(){ int i,sum=0; int a[20]; for(i=0;i<20;i++) { scanf("%d",&a[i]); } for(i=0;i<20;i++) { if(a[i
int num[20];int n[2]={0};int sum;printf("input 20 numbers:") ;for(i=0;i<20;i++){ scanf("%d",&num[i]);} for(i=0;i<20;i++){ if(num[i]>=0)n[0]++;else n[1]++;} sum=0;for(i=0;i<20;i++)if(num[i]>=0)sum=sum+num[i];printf("%d\n",n[0...
include <stdio.h> void main(){ int input, sum = 0, count = 0, Num = 3;printf("请输入20个数:\n");do { scanf("%d", &input);if(input >= 0){ sum += input;count ++;} Num --;} while(Num != 0);printf("\n非负数的个数 : %d \t 总和是: %d\n", ...