int sum=0;for(int i = 1;i<101;i++) if(i%2 == 1) sum +=sum; else sum –=sum;}return sum;int rezult;rezult=1;for(int i=2;i<101;i++)if(i%2==0)rezult=rezult-i;}elserezult=rezult+i;}}response.write("结果是"+reszult);这里是c#,照这写java,vb,c/c++,delpht什么的,语言都差不多include<stdio.h>int main(0 int sum=0; int x=1; for(int i=1;i<=100;i++) sum=sum+i*x; x=x*-1; } printf("答案=%d",sum);}void main() int i, n; do n -= 1; } while (i++ < 100); printf("结果为:%d", n);}/*请采纳*/
8,c语言编程求11213161991100的值 可不可以
#include<stdio.h>main() int i; double sum=0; for(i=1;i<=100;i++) //分母从 1 到 100 if(i%2==0) //分母是偶数用减 sum=sum-1.0/i; /*这里用 1.0/i 不能用1/i,1/i得到的整型,比如 1/5会等于0,而这里想要的是等于0.2,所以不对*/ else //分母是奇数用加 sum=sum+1.0/i; } printf("结果等于%lf\n",sum)}#include <stdio.h>int main() int i; //分母 int exp = -1; //分母的符号 double sum = 0; //最后结果 for(i = 1; i <= 5; ++i) exp = exp * (-1); //改变符号 sum = sum + 1.0 * exp / i; } printf("%lf\n", sum); return 0;}int main() float sum = 0.0; int tag = 1; int val; for(int i = 1;i <= 100;i++) val = tag *(1/i); sum += val; tag = -tag; } cout<<sum<<endl; return 0;}