2022.12.30

1、买一件上衣59元,买一件裤子70元,如果成套买的话,一套120.假设我买了m个上衣和n个裤子,问:需要花多少钱?

#include <stdio.h>
int main(int argc, const char *argv[])
{
    int yifu;
    int kuzi;
    int mon;
    scanf("%d %d",&yifu,&kuzi);
    if(kuzi>yifu)
    {
        mon=(yifu*120+(kuzi-yifu)*70);
    printf ("%d\n",mon);
    }
    else if(yifu>kuzi)
    {
        mon=(kuzi*120+(yifu-kuzi)*59);
            printf("%d\n",mon);
    }
    return 0;
}

2.给定一个整型变量 a,写两段代码,第一个设置 a 的 bit 3为1,第二个清除 a 的 bit 3.在以上两个操作中,要保持其它位不变。

int main(int argc, const char *argv[])
{
    int a;
    a=0x1<<3|0x1;
    printf("%d\n",a);
    a=0x9&0x1;
    {
        printf("%d\n",a);
    }
    return 0;
}

3、从终端输入一个字符:如果是大写的 转换成小写,如果是小写的 转换成大写,如果是 0-9 按照 %d 输出对应整型的 0-9,其他字符 转换成 #并输出。

#include <stdio.h>
int main(int argc, const char *argv[])
{
    char a;
    scanf("%c",&a);
    if(a>=65&&a<=90)
{
    printf("%c\n",a=a+32);
}

   else if(a>=97&&a<=122)
{
     a=a-32;
   printf("%c\n",a);
}
    else if(a>=48&&a<=57)
{  printf("%d\n",a=a-48);
}
    else 
{  printf("%c\n",'#');
}
    return 0;
}

4、 从键盘输入任意一个3位正整数,判断是否"水仙花数"。若是水仙花数,则输出"该三位数是水仙花数!",否则 输出“该三位数不是水仙花数!”。提示:所谓"水仙花数"是指一3位数,其各位数字立方和等于该数本身。

#include <stdio.h>
int main(int argc, const char *argv[])
{
    int num;
    scanf("%d",&num);
    int ge,shi,bai;
    bai=num/100,shi=num%100/10,ge=num%10;


    if(num==bai*bai*bai+shi*shi*shi+ge*ge*ge)
    {  printf("%d是水仙花数",num);
    }
    else
    {  printf("%d不是水仙花数",num);
    }
    return 0;
}

5、从终端随机输入三个整数分别一次赋值给变量a,b,c,按照从大到​小的顺序给a,b,c重新赋值后打a,b,c的值。例如:输入 8 3 9 ,输出 9 8 3 。

#include <stdio.h>
int main(int argc, const char *argv[])
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int temp;
    if(a<b)
    { temp=b;b=a;a=temp;
}
    if(a<c)
    { temp=c;c=a;a=temp;
}
    if(b<c)
    { temp=c;c=b;b=temp;  
}
     printf("%d %d %d",a,b,c);
    return 0;
}

6、给定一个整数,判断它能否被3,5,7整除,并输出以下信息:

1)能同时被3,5,7整除(直接输出3 5 7,每个数中间一个空格);

2)只能被其中两个数整除(输出两个数,小的在前,大的在后。例如:3 5或者3 7或者5 7,中间用空格分隔);

3)只能被其中一个数整除(输出这个除数);

4)不能被任何数整除,输出"none".

#include <stdio.h>
int main(int argc, const char *argv[])
{
    int num=0;
    scanf("%d",&num);
    if(num%3==0&&num%5==0&&num%7==0)
    { printf("%d %d %d",3,5,7);
}
    else if(num%3==0&&num%5==0&&num%7!=0)
    { printf("%d %d",3,5);
    }

    else if (num%3==0&&num%7==0&&num%5!=0)
   {printf("%d %d",3,7);
}
    else if (num%5==0&&num%7==0&&num%3!=0)
{  printf("%d %d",5,7 );
}  
   else if (num%5==0&&num%3!=0&&num%7!=0)
{  printf("%d",5);
}     
   else if (num%3==0&&num%5!=0&&num%7!=0)
{  printf("%d",3);
}    
  else if (num%3!=0&&num%5!=0&&num%7==0)
{ printf("%d",7);
}
   else 
   printf("none");
    return 0;
}
| 序号 | 日期 | 说明 | | ---- | ----------- | ---- | | 1 | 2022.12.01 | | | 2 | 2022.12.02 | | | 3 | 2022.12.03 | | | 4 | 2022.12.04 | | | 5 | 2022.12.05 | | | 6 | 2022.12.06 | | | 7 | 2022.12.07 | | | 8 | 2022.12.08 | | | 9 | 2022.12.09 | | | 10 | 2022.12.10 | | | 11 | 2022.12.11 | | | 12 | 2022.12.12 | | | 13 | 2022.12.13 | | | 14 | 2022.12.14 | | | 15 | 2022.12.15 | | | 16 | 2022.12.16 | | | 17 | 2022.12.17 | | | 18 | 2022.12.18 | | | 19 | 2022.12.19 | | | 20 | 2022.12.20 | | | 21 | 2022.12.21 | | | 22 | 2022.12.22 | | | 23 | 2022.12.23 | | | 24 | 2022.12.24 | | | 25 | 2022.12.25 | | | 26 | 2022.12.26 | | | 27 | 2022.12.27 | | | 28 | 2022.12.28 | | | 29 | 2022.12.29 | | | 30 | 2022.12.30 | | | 31 | 2022.12.31 | | | 32 | 2023.01.01 | | | 33 | 2023.01.02 | | | 34 | 2023.01.03 | | | 35 | 2023.01.04 | | | 36 | 2023.01.05 | | | 37 | 2023.01.06 | | | 38 | 2023.01.07 | | | 39 | 2023.01.08 | | | 40 | 2023.01.09 | | | 41 | 2023.01.10 | | | 42 | 2023.01.11 | | | 43 | 2023.01.12 | | | 44 | 2023.01.13 | | | 45 | 2023.01.14 | | | 46 | 2023.01.15 | | | 47 | 2023.01.16 | | | 48 | 2023.01.17 | | | 49 | 2023.01.18 | | | 50 | 2023.01.19 | | | 51 | 2023.01.20 | | | 52 | 2023.01.21 | | | 53 | 2023.01.22 | | | 54 | 2023.01.23 | | | 55 | 2023.01.24 | | | 56 | 2023.01.25 | | | 57 | 2023.01.26 | | | 58 | 2023.01.27 | | | 59 | 2023.01.28 | | | 60 | 2023.01.29 | | | 61 | 2023.01.30 | | | 62 | 2023.01.31 | | | 63 | 2023.02.01 | | | 64 | 2023.02.02 | | | 65 | 2023.02.03 | | | 66 | 2023.02.04 | | | 67 | 2023.02.05 | | | 68 | 2023.02.06 | | | 69 | 2023.02.07 | | | 70 | 2023.02.08 | | | 71 | 2023.02.09 | | | 72 | 2023.02.10 | | | 73 | 2023.02.11 | | | 74 | 2023.02.12 | | | 75 | 2023.02.13 | | | 76 | 2023.02.14 | | | 77 | 2023.02.15 | | | 78 | 2023.02.16 | | | 79 | 2023.02.17 | | | 80 | 2023.02.18 | | | 81 | 2023.02.19 | | | 82 | 2023.02.20 | | | 83 | 2023.02.21 | | | 84 | 2023.02.22 | | | 85 | 2023.02.23 | | | 86 | 2023.02.24 | | | 87 | 2023.02.25 | | | 88 | 2023.02.26 | | | 89 | 2023.02.27 | | | 90 | 2023.02.28 | | | 91 | 2023.03.01 | | | 92 | 2023.03.02 | | | 93 | 2023.03.03 | | | 94 | 2023.03.04 | | | 95 | 2023.03.05 | | | 96 | 2023.03.06 | | | 97 | 2023.03.07 | | | 98 | 2023.03.08 | | | 99 | 2023.03.09 | | | 100 | 2023.03.10 | | | 101 | 2023.03.11 | | | 102 | 2023.03.12 | | | 103 | 2023.03.13 | | | 104 | 2023.03.14 | | | 105 | 2023.03.15 | | | 106 | 2023.03.16 | | | 107 | 2023.03.17 | | | 108 | 2023.03.18 | | | 109 | 2023.03.19 | | | 110 | 2023.03.20 | | | 111 | 2023.03.21 | | | 112 | 2023.03.22 | | | 113 | 2023.03.23 | | | 114 | 2023.03.24 | | | 115 | 2023.03.25 | |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值