請問C++ 100+99+98+97+...+1問題
請問C++
100
100+99=
100+99+98=
100+99+98+97=
...
...
...
100+99+98+97+...+1=
這類的程式要怎麼打??
編譯結果要像上面那樣直接顯示
回答 (5)
✔ 最佳答案
#include<iostream>
using namespace std;
int main()
{
int i,j,sum=0;
for(i=100;i>0;i--)
{
sum=0;
for(j=100;j>=i;j--)
{
if(j!=100) cout<<"+";
cout<<j;
sum+=j;
}
cout<<"="<<sum<<endl;
}
system("pause");
return 0;
}
是像這樣?
這里很不錯aaashops。com老婆很喜歡
劆冄傂侀兤
「需求」
100
100+99=
100+99+98=
100+99+98+97=
「設定來源」
A = 100
B = (-1)
A - B = i ; prtint A$ B,i
「設定運行」
if i=1
i - B =i ; print i$
goto if
2014-08-08 14:22:27 補充:
這在很多「語言程式」當中,都是很基本的........需要特別這樣問嗎?
收錄日期: 2021-05-04 02:05:35
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20140808000010KK06168
檢視 Wayback Machine 備份