변수 뒤에 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]; 입니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2685477 | 소수점이하 출력하는거요 | 널위해 | 2025-02-18 |
2685449 | printf배우고있는데요 궁금한게있어요 (8) | 꽃큰 | 2025-02-18 |
2685393 | c언어 질문이요.... | 붕붕 | 2025-02-18 |
2685365 | 윈도우7에서 visual studio c++6.0 (1) | 빛길 | 2025-02-17 |
2685317 | segmentation fault가 나요 | 가람 | 2025-02-17 |
2685292 | 다중스택질문 | 올해1살 | 2025-02-17 |
2685231 | C언어와 닷넷에 대해서 질문!! (2) | 설아 | 2025-02-16 |
2685206 | VisualBasic 과 DEV++ 의 장단점과 만든 파일 호환 가능하나요? | 에드워드 | 2025-02-16 |
2685154 | 배열 크기조절 | 해찬솔 | 2025-02-15 |
2685124 | 수정이거 제가 뭐가 잘못한거죠 ? | 아이돌 | 2025-02-15 |
2685096 | 포인터의 고수분들 모두 보세요!! 제발 ㅠ_ㅠ 헷갈려헷갈려..갈려헷.. (7) | 치킨마루 | 2025-02-15 |
2685045 | 전처리기 질문 | 치에미 | 2025-02-14 |
2685016 | 오류 좀 확인해 주시면 감사하겠습니다 | 초코맛사탕 | 2025-02-14 |
2684917 | 알고리즘을 이용한 행렬의 전치// 문제다운 문제네요. | 뿡뿡 | 2025-02-13 |
2684868 | 양방향 연결리스트에서 실행도중 죽는 이유좀 찾아주세요. (2) | 예다움 | 2025-02-13 |
2684844 | 시계프로그램인데 도저히 모르겠어요ㅠ (1) | 비내리던날 | 2025-02-12 |
2684812 | 레포트좀도와주세요ㅠㅠ (2) | 갈매빛 | 2025-02-12 |
2684780 | 채팅창 흉내내보려고하는데요 ㅜ.ㅜ (1) | 바름 | 2025-02-12 |
2684729 | 내일 시험인데 메모리 그리는것좀 도와주세요 ㅠ (1) | 상처주지마 | 2025-02-11 |
2684701 | 버퍼 관련 질문 3가지 (이전거랑 달라요) | 한국녀 | 2025-02-11 |