我使用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++中我有这个程序:
#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位插入一个字符吗?
我正在为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) 在阅读有关memmove的内容时,我读到它可以处理MEMORY OVERLAPS,但我无法知道两个字符串之间如何发生内存重叠,以及该函数如何仍能正确复制内存块.
我已阅读以下文章.他们引用了这个,
SQL Server是一个区分大小写的后端应用程序.这意味着名为"addr"的表与名为"ADDR"的表区分开来.但是,由于Microsoft Query是基于MS-DOS的应用程序,因此无法区分案例; 因此,Microsoft Query将"addr"和"ADDR"视为同一文件.
现在我想知道他们的意思是case-sensitive back-end application什么?使用query带有安全性case-insensitivity吗?
提前致谢.
我正在学习MIPS 32位.我想问一下为什么我们签名扩展16位偏移(在单周期数据路径中),然后在存储字的情况下将其发送到ALU?
我想在我的应用程序中简化一小部分.分数类似于x/y,其中x和y是整数.我想将分数简化为最简单的形式.任何人都可以给我提示如何做到这一点.提前致谢.
编程时我遇到了一个不寻常的错误.当我在循环中初始化一个整数时,有时它表示该表达式无效,但有时它接受它.这是我的代码,它给出了错误:
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 ++很新,并且模糊编程和面向函数编程之间的区别很困惑.我从未完成模块化编程,所以我只知道模块的定义,它包含函数.所以顺序之间有什么区别(函数 -面向语言)和模块化编程?提前感谢.
编辑: 我正在阅读关于C++的OOP.It开始类似于非结构化编程,而不是模块化编程,最后是OOP,而不是结构化编程的基本概念.