zoukankan      html  css  js  c++  java
  • 编写一个程序,求s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值

    编写一个程序,求s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)的值

      1 #import <Foundation/Foundation.h>

     2 
     3 int main(int argc, const char * argv[]) {
     4     @autoreleasepool {
     5         int shu=0,he=0;
     6         for (int i=1; i<=100; i++) {
     7             shu+=i;
     8             he+=shu;
     9             //printf("he is:%d ",he);
    10         }
    11         printf("he is:%d ",he);
    12         return 0;
    13     }
    14 }

    执行结果: 

    为了更好点交流和学习,请大家在参阅博客后,留下你的疑问和宝贵意见。谢谢!!!!
  • 相关阅读:
    10.28
    10.29
    11.05周四
    数据库增删改查
    11.03Tuesday
    11.10
    连接数据库
    10.30
    11.04周三
    10.27
  • 原文地址:https://www.cnblogs.com/fshmjl/p/4546333.html
Copyright © 2011-2022 走看看