변수 뒤에 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]; 입니다.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692230 | 하노이탑 질문입니다. (1) | 미쁘다 | 2025-04-21 |
2692210 | 정보 올림피아드 문제인데.. 풀이 과정이 궁금합니다.(재귀함수) (5) | 물티슈 | 2025-04-20 |
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |