写一个c 程序计算1到100的和,并改进可以计算任意2个整数之间的和.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 13:11:51
intmain(void){inti,ans;For(i=1;i再答:�������ټ�һ��#include再问:лл
////////////////////下面是whileintsum=0;int_i=0;while(_i
最简单的求法就是使用等差数列的求和公式,参考程序如下:#includeintmain(void){intnumber;number=(0+100)*101/2;printf("%d\n",number
#includeintmain(){inti;doublesum=0.0;doublejiecheng(doublenumber);for(i=1.0;i
#includevoidmain(){inta,b;printf("a=");scanf("%d",&a);printf("b=");scanf("%d",&b);printf("\na+b=%d\n
intarea(intx,inty){returnx*y;}intgri(intx,inty){return2*(x+y);}
#includevoidmain(){intsum=0;for(inti=1;i
PublicSubqqqqq()DimiAsIntegerDimjAsIntegerDimsAsIntegerDimCAsBooleans=0Fori=2To100C=FalseForj=2Toi-1
dimiaslongdimsumaslongsum=0fori=1to100step2sum=sum+inextiprintsum
publicclassdemo{/***@paramargs*/publicstaticvoidmain(String[]args){inta=0,b=0;for(inti=1;i
#include#includevoidmain(){voidss(charstr[]);intsum,i;sum=0,i=1;for(i=1;i
假定5险一金固定是1000元,起征点是3500,程序如下: #include intmain(intargc,char*argv[]) { floatmoney,temp,total,t;
publicclasswages{intmoney;inthour;publicwages(){money=0;hour=0;}publicintweekmoney(){returnmoney*hou
#includevoidmain(){inti,sum=0;for(i=3;i
#includemain(){floata,b,s;printf("pleaceinputa,b:\n");scanf("%f%f\n",&a,&b);s=a+b;printf("%f\n",s);/
#!/bin/bashread-p"Enteranum:"numsum=0foriin$(seq$num)dosum=$((sum+i))doneecho"Sumis$sum"
楼上的好像和题目要求不符#include<stdio.h>#define N 5 //定义N的值void main(){ in
#includeintmain(){intlength,width,perimeter;printf("长:");scanf("%d",&length);printf("宽:");scanf("%d"
#includemain(){inti,m=0;for(i=1;i
//分别计算1到1000之间所有3的倍数之和和所有7的倍数之和intmain(){intsumA=0;//3的倍数的和intsumB=0;//7的倍数的和for(inti=1;i