习题 1.10 循环 50到100的和
#include<iostream> using namespace std; int main() { //calculate the sum of 50 to 100 int result = 0; for(int i=50;i<=100;i++) result += i; cout<<"result="<<result<<" "<<"using for loop"<<endl; //3825 result = 0; int i = 50; while(i<=100) { result += i; i++; } cout<<"result="<<result<<" "<<"uring while loop"<<endl; return 0; }
posted on 2011-11-29 22:30 york_software123 阅读(181) 评论(0) 编辑 收藏 举报