小编fud*_*din的帖子

如何在C中以编程方式查找闰年

我使用C制作了一个程序来查找输入的年份是否是闰年.但遗憾的是它运作不佳.它说一年是飞跃,前一年不是飞跃.

#include<stdio.h>
#include<conio.h>
int yearr(int year);
void main(void)
{
    int year;
    printf("Enter a year:");
    scanf("%d",&year);
    if(!yearr(year))
    {
        printf("It is a leap year.");
    }
    else
    {
    printf("It is not a leap year");
    }


getch();
}
int yearr(int year)
{
    if((year%4==0)&&(year/4!=0))
    return 1;
    else
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

阅读评论后,我编辑了我的编码:

#include<stdio.h>
#include<conio.h>
int yearr(int year);
void main(void)
{
    int year;
    printf("Enter a year:");
    scanf("%d",&year);
    if(!yearr(year))
    {
        printf("It is a leap year.");
    }
    else
    {
    printf("It is not a leap year");
    }


getch();
}
int …
Run Code Online (Sandbox Code Playgroud)

c leap-year

8
推荐指数
4
解决办法
3万
查看次数

C++,从'char'到'const char*'的转换无效

在C++中我有这个程序:

#include <iostream>
using namespace std;
int main(){
    string expression_input;
    cout << "User Input: " << endl;
    getline(cin, expression_input);
    expression_input.insert(0, '(');   //error happens here.
    expression_input.append(')');
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

prog.cpp:15: error: invalid conversion from ‘char’ to ‘const char*’

prog.cpp:15: error:   initializing argument 2 of 
‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, 
_Traits, _Alloc>::insert(typename _Alloc::rebind<_CharT>::other::size_type, 
const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, 
_Alloc = std::allocator<char>]’
Run Code Online (Sandbox Code Playgroud)

我要char转到const char*哪里?我不能在字符串的第0位插入一个字符吗?

c++ string pointers

8
推荐指数
2
解决办法
3万
查看次数

8086/8088中有多少个寄存器?

我参加了计算机体系结构课程,我理解处理器有32个寄存器,每个32位.现在我正在学习计算机体系结构课程,其中我读到8086只有8个寄存器.但是我读过的本书和这个网站显示了很多寄存器.我对8086和8088的寄存器感到困惑.请帮帮我.谢谢

注意:

我很好地理解了不同处理器中不同的寄存器大小.我只是对寄存器的数量感到困惑.谢谢

cpu x86 cpu-registers microprocessors

8
推荐指数
2
解决办法
5万
查看次数

音频无法在html5中运行

我正在为HTML5网站添加音频.音频可以与FireFox和IE一起使用,但不会在FireFox中显示和播放.任何想法为何和解决方案?提前致谢.

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<audio controls="controls" autoplay="autoplay">
 <source src="cd.mp3" type="audio/mpeg" />
 Your browser does not support the audio element.
</audio>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

audio firefox html5 mp3

8
推荐指数
1
解决办法
1万
查看次数

内存重叠是如何发生的以及如何控制?

在阅读有关memmove的内容时,我读到它可以处理MEMORY OVERLAPS,但我无法知道两个字符串之间如何发生内存重叠,以及该函数如何仍能正确复制内存块.

c memmove

7
推荐指数
1
解决办法
6730
查看次数

查询中的表名是否不区分大小写?

我已阅读以下文章.他们引用了这个,

SQL Server是一个区分大小写的后端应用程序.这意味着名为"addr"的表与名为"ADDR"的表区分开来.但是,由于Microsoft Query是基于MS-DOS的应用程序,因此无法区分案例; 因此,Microsoft Query将"addr"和"ADDR"视为同一文件.

现在我想知道他们的意思是case-sensitive back-end application什么?使用query带有安全性case-insensitivity吗?

提前致谢.

sql sql-server

7
推荐指数
1
解决办法
1万
查看次数

为什么我们在加载字指令中使用Sign Extend?

我正在学习MIPS 32位.我想问一下为什么我们签名扩展16位偏移(在单周期数据路径中),然后在存储字的情况下将其发送到ALU?

mips isa mips32

7
推荐指数
2
解决办法
2万
查看次数

如何简化分数

我想在我的应用程序中简化一小部分.分数类似于x/y,其中x和y是整数.我想将分数简化为最简单的形式.任何人都可以给我提示如何做到这一点.提前致谢.

c c++ algorithm math greatest-common-divisor

7
推荐指数
2
解决办法
3万
查看次数

For循环表示在循环中初始化整数时表达式语法错误

编程时我遇到了一个不寻常的错误.当我在循环中初始化一个整数时,有时它表示该表达式无效,但有时它接受它.这是我的代码,它给出了错误:

int pow(int x,int n);
int main()
{
    int x,n,result;
    printf("Enter a number:\n");
    scanf("%d",&x);
    printf("Enter its power:\n");
    scanf("%d",&n);
    result=pow(x,n);
    printf("Result is %d\n",result);
    getch();
    return 0;
}
int pow(int x,int n)
{   
    for(int i=1;i<n;i++)   //<-- here it says that declaration syntax error
    x=x*i;
    return x;
}
Run Code Online (Sandbox Code Playgroud)

当我改变它时:

int pow(int x,int n)
{   
    int i;
    for(i=1;i<n;i++)  
    x=x*i;
    return x;
}
Run Code Online (Sandbox Code Playgroud)

c

6
推荐指数
3
解决办法
6908
查看次数

函数和模块之间的差异是什么?

我对c ++很新,并且模糊编程面向函数编程之间的区别很困惑.我从未完成模块化编程,所以我只知道模块的定义,它包含函数.所以顺序之间有什么区别(函数 -面向语言)和模块化编程?提前感谢.

编辑: 我正在阅读关于C++的OOP.It开始类似于非结构化编程,而不是模块化编程,最后是OOP,而不是结构化编程的基本概念.

functional-programming modular

6
推荐指数
1
解决办法
1万
查看次数