[问题] 关于抓取数列

楼主: rockken   2015-03-10 16:23:19
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dev-C++
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
NO 只有基本的 include <stdio.h>
问题(Question):
抓阵列取值有时会出错
喂入的资料(Input):
预期的正确结果(Expected Output):
如图。阵列值都是一。
错误结果(Wrong Output):
可是当N 变大时等于60, 他会出现 2292658 这种怪数字。
可是 N=99 又没问题。 不知道为什么,求大师解救。
程式码(Code):(请善用置底文网页, 记得排版)
#include <stdio.h>
#define N 60
int main(){
int score1[N],score2[N];
int i,j,s=0,ds=0;
// 输入两个长度100的数列
for (i=1;i<=N;i++){
score1[i]=1,score2[i]=1 ;
printf("%6d\n",score1[i]);
printf("%6d\n",score2[i]);
printf("%6s\n","
作者: wenyonba (射后不理很XX啊!!!!)   2015-03-10 16:48:00
阵列长度为N,Index是从0~N-1喔,不是1~N
作者: KawasumiMai (さあ、死ぬがいい)   2015-03-10 16:58:00
i=0;i<n 应该是写阵列的习惯了= =
楼主: rockken   2015-03-10 17:17:00
谢谢两位,太久没写C 。 以为跟R 一样 S[0] 没有定义以解决 3Q

Links booklink

Contact Us: admin [ a t ] ucptt.com