对大家有帮助的问答会被标记为“推荐”,看完课程过来浏览一下别人提的问题,会帮你学得更全面
#include <iostream> using namespace std; int main() { cout<<"Hello world"<<endl; renturn 0; }
哪里不对啊
void swap(int& a, int& b)
{ int t = a; a = b; b = t;}
void bubble_sort(int* a, const int N)
{
for(int j=0; j<N-1; j++){
for(int i=0; i<N-1; i++){
if(a[i]>a[i+1]) swap(a[i],a[i+1]);
}
}
}
void show(int* a, const int N)
{
for(int i=0; i<N; i++) cout << a[i] << " ";
cout << endl;
}
老师可以解释注释一下 这一段吗
#include <iostream>
#include<limits>
using namespace std;
int main(){
unsigned long long a=std::numeric_limits<long long int>::max();
cout <<sizeof (a)<<endl;
return 0;
}
就是写完这些代码运行时还是8而不是最大值
typedef void (*MYF)(int);
typedef int (*MYF)(int);
分别都是什么意思
*p++=(x%10)+‘0’
老师这个+‘0’得到的是ASCII,那*p里面存的不应该就是ASCII值吗,比如x%0=3,3+‘0’他的ASCII值是51呀,那为什么输出的时候是结果还是3呀
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
char buf[100];
char a[]="abc";
char b[]="1234";
const char *s1=a;
const char *s2=b;
strcpy(buf,s1);
strcat(buf,s2);
cout<<buf<<endl;
cout<<s1<<endl;
cout<<*s1<<endl;
return 0;
}
//老师,我对这里的指针有点问题,我把拼接那里的库函数的例子写成这样。char*s1=a,那s1不是储存了a的地址吗?我cout s1却不是一个地址
#include<iostream> using namespace std; int main() { int a = 5, b = 8; int c; c = a - b; if(c<0){ int diff = c + 12; } cout << diff << endl; return 0; }
算5月到明年8月共有多少个月,这段代码哪里错了诶
n = 0; for (int i = 2; i < x; i++) if (x % i == 0) data[n++] = i; data[n] = -1;
这里n不是重新赋值为0了吗,那为什么后面的data[n++]=i这样下来,运行的结果是data[0]=2;