- UID
- 42089
- 帖子
- 1
- 精華
- 0
- 積分
- 10
- 金幣
- 10
- 威望
- 0
- 推廣
- 0
- 閱讀權限
- 5
- 在線時間
- 0 小時
- 註冊時間
- 2013-1-11
|
1樓
發表於 2013-1-15 10:05
| 只看該作者
[討論] 請問!版大或其他大大們~
#include<stdio.h>
void main(void)
{
int n,i,x;
printf("Input the number>");
scanf("%d",&n);
x=0;
i=1;
while(i<=n){
x=x+i*i*i;
printf("%d",i);
i=i+1;
}
}
以上是原來的程式,題目是問說當輸入n值為3時,每個i值印出之x值為何?
但是我在這個網站
訪客無法瀏覽此圖片或連結,請先註冊或登入會員。
線上執行時,卻出現error
我稍微修改後,如下
#include<stdio.h>
int main(void)
{
int n,i,x;
printf("Input the number>");
scanf("%d",&n);
x=0;
i=1;
while(i<=n){
x=x+i*i*i;
printf("%d",i);
i=i+1;
}
}
可是結果
# 2: hide clone input 2 seconds ago
結果: success time: 0.02s 記憶體: 2728 kB 回傳值: 0
input:
3
output:
Input the number>0123
請問 大大~們 這是程式要的結果嗎?如果不是的話,程式要修改成如何,才是題目要的結果?謝謝!
|
|