변수 뒤에 i를 붙이고 싶습니다.
튼튼
질문 제목 : 변수 뒤에 i를 붙이고 싶습니다.질문 요약 :
안녕하세요!! c언어 초보입니다.
프로그램 작성중에 궁금한 사항이 있어서 들렀어요~
tpump(1), tpump(2) 라는 변수를 선언하고 i=i+1; 로 해서 tpump(i)로 앞에서 선언한 변수tpump(1), tpump(2)를 받아오고 싶은데받기도 전에에러가 뜨네요 왜이러는 건가요 ㅠㅠ?질문 내용 :
void main()
{
long seed,nseed;
int p, queue = 0, totque = 0, time=0, totarr=0, arrive, tstep = 1, i;
// prarr = 1.0/(60/27) 참고 //
float prarr=0.454545, tpump(1)=0.0, tpump(2)=0.0, tlimit=150, u=0, aveque=0;
file *output; seed=seed;
nseed=seed;
output=fopen(limsungmin.txt,wt); fprintf(output, simulation for a queueing system \n\n);
fprintf(output,the time step = %d \n,tstep); //분의 시간증가
fprintf(output,the time limit = %3.0f \n,tlimit); //시간의 증가값
fprintf(output,the arrival probability = %4.2f \n,prarr); //도착여부의 확률?
fprintf(output,the poisson mean = %1.0f \n,mean);
fprintf(output,the seed = %ld \n\n,seed);
fprintf(output, time arrival queue tpump\n); while (time tlimit)
{
time = time + tstep;
arrive = 0; random(&seed, &u); if (u (prarr*tstep))
{ arrive = 1;
queue = queue + arrive;
totarr = totarr + 1;
}
i=0;
while (i=2)
i=i+1;
if (tpump(i) 0.0)
{ tpump(i) = tpump(i) - tstep;/fonep;
if (tpump(i) 0.0) tpump(i) = 0.0;
}
if ((tpump(i) == 0) && (queue != 0))
{ queue = queue - 1;
poissn(&nseed,&p);
tpump(i) = p;
}
totque = totque + queue;
fprintf(output, %3d %d %2d %2.0f \n,time,arrive,queue,tpump);
}
aveque = totque / (tlimit/tstep);
fprintf(output, mean queue length = %4.2f \n,aveque);
fprintf(output, the total arrivals = %d \n,totarr);
fprintf(output, the total queue = %d \n,totque);
fclose(output);
}
-----------------------------------------------------------------------------------------------------------
-
비
아!! 해결했네요.. 감사합니다!!
-
호빵녀
하아,,, 저는 tpump가 함수인 줄 알고 있다가 수다님 말씀 보고 알았네요...
float tpump[2] = {0.0, 0.0};
이렇게하시구 tpump[0], [1]로 접근하시면 됩니다. -
희1미햬
원하시는게 배열을 원하시는거같은데.
tpump(i) 가아니고
int tpump[10]; 입니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2699024 | C언어 공부하려는데 도와주세요!!! (2) | 달님 | 2025-06-22 |
2698994 | 날짜 계산하는 C 코드 짜고 있는데 꽉 막혀서 질문드립니다.. (6) | 별 | 2025-06-22 |
2698967 | 파일삭제 윈도우 폴더까지 접근하게하는 함수가 뭔가요 (2) | 샤인 | 2025-06-21 |
2698938 | c언어 메모리질문 (3) | 나래 | 2025-06-21 |
2698909 | 서비스 요청 고객 관리 프로그램 짜는것좀 도와주세요ㅜㅜ (4) | 궁수자리 | 2025-06-21 |
2698882 | 프로그래밍좀 짜주세요 (3) | 황예 | 2025-06-21 |
2698855 | 카프-라빈 알고리즘 코딩 분석좀 도와주세요.. | 꽃봄 | 2025-06-20 |
2698829 | 학점계산기 (7) | MyWay | 2025-06-20 |
2698782 | 기초적인 함수 질문이요ㅠㅠㅠㅠ | 내담 | 2025-06-20 |
2698749 | 프로그램 짜던 도중 패닉입니다...ㅜ | 파랑 | 2025-06-19 |
2698719 | 조건부컴파일 질문입니다.~ (2) | 큐트 | 2025-06-19 |
2698693 | 재귀 함수 에러 | 바닐라 | 2025-06-19 |
2698673 | 고민이있는데 들어좀주세요!! (1) | 초코맛캔디 | 2025-06-19 |
2698644 | 1부터 n까지의 합을 구하는데 엄청긴숫자의 합을 구할때는 어떻게 해야하나요? (4) | 슬우 | 2025-06-18 |
2698616 | 다른 함수로 안넘어갑니다..;;; | 도1도캣 | 2025-06-18 |
2698587 | 배열하다 막혀서... (3) | WhiteCat | 2025-06-18 |
2698559 | 문자열을 비우는방법 (2) | 하늘 | 2025-06-18 |
2698528 | 착하고 친절한 선생씌구해염~ㅋㅋ (4) | 옆집언니야 | 2025-06-17 |
2698502 | 자료구조 큐 | 캔서 | 2025-06-17 |
2698477 | 실행화면 배경문의요 | 선아 | 2025-06-17 |