c语言基础1的作业

#include <stdio.h>

int main(int argc, const char * argv[])
{

    // insert code here...
    //计算十进制42转换为二进制、八进制、十六进制分别对应的值    int number1=42;
   /* int number1=42;
   for (number1; number1>=1; ) {
        if ( number1%2==0)
            printf("1");
        else
            printf("0");
        number1=(int )number1/2;
    }*/
 
    
    
    
    //5、    (*)打印下面图形:
   /*
    printf("  *\n");
    printf(" * * \n");
    printf("* * *\n");
    */
    
 /*
    for (int i=0; i<3; i++) {
        for (int j=0; j<3-i; j++) {
            printf(" ");
            
            }
        for (int p=0; p<i+1; p++) {
            printf("* ");
        }
        
        
        printf("\n");
      }
   */
//6、编写一个程序,要求用户输入一个美元数量,然后显示出增加%5税率后的相应金额。格式如下所示:
    //Enter an amount:100.00
    //With tax added:$105.00
    
    //%g 保留有效数字  只保留非零数字
//   float money;
//    scanf("%f",&money);
//    printf("Enter an amount:%.2f\n",money);
//    money=money*1.05;
//    printf("With tax added:$%.2f\n",money);
    
    
    
    
    //7、(**)从键盘输入两个实数a和b,输出a占b的百分之几。小数点后保留2位。
    //例如:输入1和4,输出:25.00%
    /*
    
    
    float a,b;
    scanf("%f%f",&a,&b);
    printf("%.2f%%\n",(a/b)*100);
    
    
    */
    
    
    
    
    //8、(**)编写一个程序,要求用户输入一个美金数量, 然后显示出如何用最少的2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     0美元、10美元、5美元和1美元来付款:
   // Enter a dollar amout:93
   // $20  bills: 4
   // $10  bills: 1
   // $5   bills:0
   // $1   bills:3
    
   /*
    int money;
    scanf("%d",&money);
    printf("$20  bills:%d\n$10  bills:%d\n$5   bills:%d\n$1   bills:%d\n",money/20,money%20/10,money%20%10/5,money%20%10%5/1);
    
    */
//    int a,b,c,d,money;
//    printf("请输入金额:\n");
//    scanf("%d",&money);
//    
//    for (a=0; a<=money/20; a++) {
//        
//        
//        for (b=0; b<=(money-20*a)/10; b++) {
//            for (c=0; c<=(money-20*a-b*10)/5; c++) {
//                if (money-a*20-b*10-c*5>0)
//                    d=money-a*20-b*10-c*5;
//                printf("%d %d %d %d\n",a,b,c,d);
//            }
//        }
//    }




    
   // int a,b;
   // scanf("%d%d",&a,&b);
   // printf("和:%d\n差:%d\n积:%d\n商:%d\n余数:%d\n",a+b,a-b,a*b,a/b,a%b);
    
  // int a=65;
  //  char b=‘A‘;
  // printf("%d\n%c\n",b,a);
    
    return 0;
}

c语言基础1的作业,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。