#include<iostream> using namespace std; int main() { int arr[10] = { 1,2,3,4,5,6,7,8,9,10}; cout << "整个数组占用内存空间为:" << sizeof(arr) << endl; cout << "每个元素占用内存为:" << sizeof(arr[0]) << endl; cout << "数组中元素个数为:" << sizeof(arr) / sizeof(arr[0]) << endl; cout << "数组首地址为:" << (int)arr << endl; }
为什么我这里的查看数组首地址使用int进行强转要报错
#include <iostream>
using namespace std;
void set_nth(unsigned char* data,int n,bool x)
{
int a=n/8,b=n%8;
if(x)
data[a] |= 0x80>>b; //?????原来的data[a]是多少?
}else{
data[a] &= ~(0x80>>b);
}
bool get_nth(unsigned char* data,int n)
return data[a] & (0x80 >> b);
int main()
unsigned char data[20];
set_nth(data,100,true);
cout << get_nth(data,100) << endl;
return 0;
x = y++ // 含义是: y0 = y; y = y + 1; x = y0;
既然赋给X的是原来的y值,那写成y++有什么意义?
double a[3][2] = {{2,4},{5,2},{1,1}}; for(int i=0; i<3; i++){ a[i][0] -= a[2][0]; a[i][1] -= a[2][1]; } double s = fabs(a[0][0]*a[1][1] - a[0][1]*a[1][0]) * 0.5;
a【3】【2】里面的3 ,2表示什么
a[i][0] -= a[2][0]; a[i][1] -= a[2][1];
这个什么意思
#include<iostream> #include<ctime>//time系统时间头文件包含 using namespace std; int main() { //添加随机数种子,作用利用当前系统时间生成随机数,防止每次随机数都一样 srand((unsigned int)time(NULL)); int num = rand() % 100 + 1; int val = 0; while(num=50){ cin << val; if(num<val) { cout << "猜测的数过大" <<; } else if(num<val) { cout << "猜测的数过小" <<; } else { cout << "猜对了,退出游戏" <<; } break; } return 0; }
rand为什么用不起呢,报错rand未声明
这个find的函数是怎么找的?
int a[9] = {9,7,2,5,3,6,1,4,8}; int m = a[0]; for(int i=1; i<9; i++){ if(a[i]>m) m = a[i]; } cout << m << endl;
这里面a【0】代表什么?
#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月共有多少个月,这段代码哪里错了诶
#include <iostream> using namespace std; int main() { cout<<"Hello world"<<endl; renturn 0; }
哪里不对啊
&a什么意思,怎么用的?
分解质因数
90 = 2 x 3 x 3 x 5 设计思路:
90 = 2 x 3 x 3 x 5
1for(i 从 2 到 n-1){2 if(n 能除开 i){3 输出 i4 n = n / i5 设法阻止 i 的自增行为6 }7}8if(剩下的 n > 1) 输出 n;
如何设计程序
for(int j=1; j<=9; j++){ 2 for(int i=1; i<=j; i++){ 3 int k = i * j; 4 cout << j << "x" << i << "=" << k << " "; 5 } 6 cout << endl; 7}
为什么去掉cout << endl后排列就不整齐了
这个99乘法表里输出运行时的直角三角形是如何形成的
int score = 100; 2int a = score - 60; 3char level = 'E'; 4while(true){ 5 if(a<0) break; 6 level--; 7 a -= 10; // a = a - 10; 8 if(level=='A') break; // 封顶 9} 10cout << level << endl;
这里的while后面圆括号里为什么写个true
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637