C语言基础程序设计
[-55]反=11111111 11111111 11111111 11001000
[-55]补=11111111 11111111 11111111 11001001
#include
int main( )
{
int m = 177 ;
printf( "%o\n" , m ) ;
return 0 ;
}
帮忙看看这个的运行结果是多少?
运行结果是261
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
srand((unsigned)time(NULL));
int cnt = 0, sum = 0;
int num;
for (int i = 0; i < 100; i++) {
num = rand() % 101;
if (num % 3 == 0) {
cnt++;
sum += num;
}
}
double avg = 1.0 * sum / cnt;
printf("能被3整除的数有%d个\n", cnt);
printf("能被3整除的数的平均值是%f\n", avg);
return 0;
}
#include <stdio.h>
void fun(int n) {
double s = 0;
int sign = 1;
for (int i = 1; i <= n; i++) {
s += sign * 1.0 / i;
sign = -sign;
}
printf("%f\n", s);
}
int main(void) {
int n;
scanf("%d", &n);
fun(n);
return 0;
}