2014-10-28 2 views
1

할당 : 사용자로부터 초를 읽고 시간, 분 및 초의 최대 수를 반환하는 프로그램을 작성하십시오. (예를 들어 9954은 CU 2 시간 45 분을 의미 SI 54초)dev C++로 실행시 간단한 C 프로그램, 오류

내 프로그램 : 내가 (초)을 입력 한 후 나는 사물과 dev에 C를 많이 시도했습니다

#include <stdio.h> 
#include <stdlib.h> 
#include <math.h> 

main() 
{ 
int secunde1,secunde2,minute,ore;   /* secunde1= number of seconds entered 
printf("Introduceti numarul de secunde:\n"); /*"Enter the number of seconds" 
scanf("%d",secunde1);      /*reads number of seconds from input 


secunde2 = secunde1%60;   /*forumla for seconds (second1 = number of seconds entered)  

minute = secunde1/60;   /*formula for a minute 
ore = minute/60;     /*formula for one hour 


printf("%d secunde inseamna %d ore , %d minute si %d secunde", secunde1 , ore , minute , secunde2); 

/*" x seconds mean x hours, x minutes and x secods" 

} 

는 ++ 나에게 오류를 제공 창문에. (나는 dev C++ 클래스를 사용해야한다.)

dev C++ 5.7.1에서이 작업을해야합니다.

+1

먼저 더 나은 r 경고와 디버그 정보 ('gcc -Wall -Wextra -g')를주고 디버거 ('gdb')로 디버깅 할 수있는 [ecc] 컴파일러 ([GCC] (http://gcc.gnu.org/) . 일단 잘 실행되면, 오래된 dev C++ 컴파일러 (C 모드에서 사용)로 컴파일하십시오. [scanf (3)] (http://man7.org/linux/man-pages/man3/scanf.3.html)의 문서를 읽으십시오. 그 결과를 테스트해야합니다. –

답변

2

당신은 주요 기능은해야 다른 노트에

scanf("%d",secunde1); 

    scanf("%d",&secunde1);      

을 변경해야 INT 주 (무효) 및 의견 블록이 모두 열려 있습니다. 컴파일러를 많이 그걸 허용하지 않습니다, 당신은 당신이

secunde2 = secunde1%60;   /*forumla for seconds (second1 = number of seconds entered)*/ 
    ore = secunde1/3600;     /*formula for one hour*/ 
    minute = secunde1/60 - ore*60; 
처럼 뭔가에 수학 함수를 변경할 수있는 방법으로

//mycomment 

또는

/* my comment */ 

에 귀하의 코멘트 스타일을 변경할 수 있습니다

큰 숫자에 대해 원하는 출력을 얻으려면

+0

젠장, 피곤하고 그것을 보지 못했습니다. 고마워. –

+1

그리고'gcc -Wall -Wextra -g'를 사용한다면 실수에 대해 [GCC] (http://gcc.gnu.org/) 컴파일러로부터 경고를 받게됩니다. 따라서 더 나은 컴파일러를 사용해야합니다. –

+0

감사합니다. 또한 0-60 범위에서 몇 분 동안 출력이 나오는지 확인했습니다. –