找回密码
 立即注册
楼主: 小甲鱼

[课后作业] S1E6:数据类型 | 课后测试题及答案

 荐  火... [复制链接]
发表于 2021-5-2 00:05:21 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-2 09:59:12 | 显示全部楼层
朕来啦
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-2 23:51:49 | 显示全部楼层
0、long long int
1、1字节
2、sizeof()运算符
3、8个bit
4、char
5、FE
6、unsigned int
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 09:41:31 | 显示全部楼层
#include<stdio.h>
#include<math.h>
int main()
{
        int i;
        long double sum , temp ,weight;
        for(i=0;i<64;i++)
        {
                temp=pow(2,i);
                sum=sum+temp;
        }
        weight=sum/25000;
        printf("舍汗王应该给予达依尔%lf\n",sum);
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 10:18:48 | 显示全部楼层
法
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-3 14:51:29 | 显示全部楼层
1.
  1. #include <stdio.h>
  2. #include <math.h>

  3. int main()
  4. {
  5.         int result = pow(1,2) + pow(2,3) + pow(3,4) + pow(4,5) + pow(5,6);

  6.         printf("运算结果是:%d\n", result);

  7.         return 0 ;
  8. }
复制代码

2.这题出错了
  1. #include <stdio.h>
  2. #include <math.h>

  3. int main()
  4. {
  5.         unsigned long long int(count);
  6.         unsigned long long int(weight);
  7.         unsigned long long int(temp);
  8.         int i;

  9.         for (i=0; i < 64; i++)
  10.         {
  11.                 temp = pow(2,i);
  12.                 count = count + temp;
  13.         }

  14.         weight = (count / 25000) * 2;

  15.         printf("舍罕王应该给:%u颗麦子!\n", count);
  16.         printf("如果每25000颗麦子重1千克,那么这些麦子共重:%u斤!\n",weight);
  17.         return 0;
  18. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 16:53:54 | 显示全部楼层
i love fishc
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 18:53:49 | 显示全部楼层
.
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-3 20:06:24 | 显示全部楼层
好好好
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 21:18:37 | 显示全部楼层
0.long long int
1.bit
2.是的
3.4
4.char
5.E F
6.unsigned int
7.只会根据你的输入输出

0.#include<stdio.h>
#include<math.h>

int main()
{
        printf("%f\n", pow(1,2) + pow(2,3) + pow(3,4) + pow(4,5));

        return 0;
}

1.#include<stdio.h>
#include<math.h>

int main()
{
        double sum, i, temp, weight;
        sum = 0;

        for (i = 0; i < 64; i++)
        {
                temp = pow(2, i);
                sum = sum + temp;
        }

        weight = sum / 25000;

        printf("%.0f\n", sum);
        printf("%.0f\n",weight);

        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-3 23:03:24 | 显示全部楼层
looklook
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-4 00:02:18 | 显示全部楼层
yes
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-4 11:35:29 | 显示全部楼层
#include<stdio.h>
#include<math.h>

int main()
{
        int x;
        x=pow(1,2)+pow(2,3)+pow(3,4)+pow(4,5)+pow(5,6);
        printf("%d",x);
       
        return 0;
       
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-4 17:14:48 | 显示全部楼层
0.long long int
1.short int
2.不是,是个预算符
3.8
4.布尔类型
5.BDF
6.unsinged int
7.布尔类型只表示两个值:真或假
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

发表于 2021-5-4 17:27:07 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-4 17:56:44 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-4 21:08:40 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-5 06:40:36 | 显示全部楼层
f
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-5 19:09:34 | 显示全部楼层
hh
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-5 21:19:11 | 显示全部楼层
/*
#include<stdio.h>
int main()
{
        int i;
        char j;
        float k;
        i = 123;
        j = 'C';
        k = 3.14;
        printf("size of int is %d\n",sizeof(int));        //sizeof(对象);sizeof运算符用于获得数据类型或表达式的长度;
        printf("size of i is %d\n",sizeof(i));
        printf("size of char is %d\n",sizeof(char));
        printf("size of j is %d\n",sizeof j);
        printf("size of float is %d\n",sizeof(float));
        printf("size of k is %d\n",sizeof k);
        return 0;
}
*/
/*
#include<stdio.h>
int main()
{
        printf("int = %d\n",sizeof(int));
        printf("short int = %d\n",sizeof(short));
        printf("long int = %d\n",sizeof(long));
        printf("long long int = %d\n",sizeof(long long));
        printf("char = %d\n",sizeof(char));
        printf("_Bool = %d\n",sizeof(_Bool));
        printf("float = %d\n",sizeof(float));
        printf("double = %d\n",sizeof(double));
        printf("long double = %d\n",sizeof(long double));
        return 0;
}
*/
/*#include<stdio.h>
int main()
{
        short i;
        unsigned short j;        //无符号用"%u"
        i = -1;
        j = -1;
        printf("%d\n",i);
        printf("%u\n",j);       
        return 0;
}
*/

//作业;求 1^2 + 2^3 + 3^4 + 4^5 + 5^6 的值?
/*
#include<stdio.h>
#include<math.h>
int main()
{
        int x;
        x = pow(1,2)+pow(2,3)+pow(3,4)+pow(4,5)+pow(5,6);
        printf("x = %d\n",x);
        return 0;
}
*/
#include<stdio.h>;
#include<math.h>

int main()

{
        short int i;
        long long int sum,temp,weight;
        for (i=0;i < 64; i++)
        {
                temp = pow(2,i);
                sum = sum+temp;
        }
        weight = sum/25000;
       
        printf("舍罕王应该给予达依布尔%d 粒麦子!\n",sum);
        printf("如果每25000粒麦子为1kg,那么应该给%d 公斤麦子!\n",weight);
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 顶 踩

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|鱼C工作室 ( 粤ICP备18085999号-1 )

GMT+8, 2026-11-25 23:01

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表