# e340: 差分練習 ## [題目連結](https://zerojudge.tw/ShowProblem?problemid=e340) ## 解題想法 * 除了第一項,其他均由後項減前項求得 ## 遭遇到的困難 * 別忘記第一項(陣列第零項) ## 花費的時間:3分鐘 ## 程式碼 ```cpp=01 #include<cstdio> int main(){ int n; scanf("%d",&n); int a[n],i; for(i=0;i<n;i++)scanf("%d",&a[i]); printf("%d ",a[0]); for(i=1;i<n;i++)printf("%d ",a[i]-a[i-1]); return 0; }
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up