c - 简单的 C 程序,使用 dev c++ 执行时出错

标签 c

<分区>

作业:编写一个程序,从用户那里读取秒数并返回最大小时数、分钟数和秒数。 (例如 9954 表示 cu 2 小时 45 分 şi 54 秒)

我的程序:

#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++ 上课)。

我需要在 dev C++ 5.7.1 中完成这项工作。

最佳答案

你需要改变你的

    scanf("%d",secunde1);  

    scanf("%d",&secunde1);                     

换个说法 你的主要功能应该是 int 主要(无效) 并且您的评论区都保持打开状态。很多编译器不会接受,你可能想把你的评论风格改成

 //mycomment 

/* my comment */

顺便说一句,您可能想将您的数学函数更改为类似的东西

    secunde2 = secunde1%60;          /*forumla for seconds (second1 = number of seconds entered)*/
    ore = secunde1/3600;                 /*formula for one hour*/
    minute = secunde1/60 - ore*60;

为更大的数字获得所需的输出

关于c - 简单的 C 程序,使用 dev c++ 执行时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26618674/

相关文章:

c++ - stdout 除了控制台窗口之外还有其他东西吗?

c - 有什么方法可以修改此函数,以便它删除数组中的前一个元素 - C

c - C 语言的 12 个月日历

c - 如何在 C 中使用 PlaySound

c - 为什么 printf( ) 在重新打开标准输出流后工作异常

c - 将单个值分配给多个变量

c - mmap、msync 和 linux 进程终止

c - 通过引用与通过值传递 int 的好处?

c - float的printf如何不打印正确的浮点值

c - fork 进程的执行顺序