python 与 C实现1-100和的输出

python 实现:

 1 def main():
 2     S_sum = 0
 3     count = 1
 4     while count <= 100:
 5         S_sum += count
 6         count += 1
 7     print(S_sum)
 8 
 9 
10 if __name__ == "__main__":
11     main()

C实现:

 1 #include <stdio.h>
 2 
 3 int main()
 4 {
 5     int count = 1;
 6     int sum = 0;
 7     while(count <=100)
 8    { 
 9     sum = sun + count;
10     count ++;
11    }
12 printf("%d",sum);
13     return 0;
14 }

猜你喜欢

转载自www.cnblogs.com/xudapeng/p/12525889.html