int 的返回值是return 0;而void的返回值是return;這兩個(gè)整形很容易記憶錯(cuò)誤
2023-01-08
說的對(duì)啊,不論是哪種數(shù)據(jù)類型,都不過是內(nèi)存中的一段二進(jìn)制而已,唯一的區(qū)別就是看你以何種類型去使用罷了
2023-01-06
課程代碼問題不少,continue相關(guān)的代碼想要實(shí)現(xiàn)的效果應(yīng)該是依次輸出除了下標(biāo)為10的長(zhǎng)度為100的數(shù)組的各個(gè)元素,代碼應(yīng)該是if(i == target)而不是if(array[i] == target)。
2023-01-03
最贊回答 / 慕村2333375
int是4個(gè)字節(jié),32位bit(1位符號(hào)+31位數(shù)字),取值范圍(+2,147,483,647? ?~? -2,147,483,648),你的變量int a = 10000000000000 大于int的上界所以報(bào)錯(cuò);
最新回答 / 紀(jì)念安
直接打印sizeof(int)就可以了
最贊回答 / imyd.com.cn
你也可以不加,像這樣引用命名空間using namespace std;#include<iostream>int?main(){int?a=0;int?b=0;cin>>a>>B;}這樣你就能明白std::的含義了?? 望采納!
2022-12-25
void change(int *a, int *b) {
int c = *a;
*a = *b;
*b = c;
}
int fact(int a) {
if (a == 1) {
return 1;
}
else {
return a * fact(a - 1);
}
}
int c = *a;
*a = *b;
*b = c;
}
int fact(int a) {
if (a == 1) {
return 1;
}
else {
return a * fact(a - 1);
}
}
2022-12-07
最贊回答 / weixin_慕標(biāo)4093610
利用sleep()函數(shù),沒輸出一個(gè)函數(shù)都等待相應(yīng)的時(shí)間,以達(dá)到動(dòng)態(tài)效果
2022-12-07
#include <iostream>
int main(int argc,char** argv)
{
int a=5;
int b=10;
double c = 5.5;
std::cout
<<"a+b="<<a+b
<<"\na-b="<<a-b
<<"\na*b="<<a*b
<<"\na/b="<<double(a)/double(b)
<<"\na+c="<<a+c
<<std::endl;
}
int main(int argc,char** argv)
{
int a=5;
int b=10;
double c = 5.5;
std::cout
<<"a+b="<<a+b
<<"\na-b="<<a-b
<<"\na*b="<<a*b
<<"\na/b="<<double(a)/double(b)
<<"\na+c="<<a+c
<<std::endl;
}
2022-12-05
#include <stdio.h>
#include <iostream>
int main(int argc,char** argv)
{
std::cout<<"char:"<<sizeof(char)
<<"\nshort"<<sizeof(short)
<<"\nint:"<<sizeof(int)
<<"\nlong:"<<sizeof(long)
<<"\nlong long:"<<sizeof(long long)
<<std::endl;
return 0;
}
#include <iostream>
int main(int argc,char** argv)
{
std::cout<<"char:"<<sizeof(char)
<<"\nshort"<<sizeof(short)
<<"\nint:"<<sizeof(int)
<<"\nlong:"<<sizeof(long)
<<"\nlong long:"<<sizeof(long long)
<<std::endl;
return 0;
}
2022-12-05