码迷,mamicode.com
首页 > 编程语言 > 详细

c语言基础1的作业

时间:2014-07-16 23:20:11      阅读:394      评论:0      收藏:0      [点我收藏+]

标签:io   for   re   c++   c   ar   

#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的作业,布布扣,bubuko.com

c语言基础1的作业

标签:io   for   re   c++   c   ar   

原文地址:http://www.cnblogs.com/xxdgeren/p/3811247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!