1-1 Input three integers and output the average number. Keep three decimal places. 

#include<stdio.h>
//#include<math.h>
int main()
{
int a, b, c;
scanf("%d%d%d",&a,&b,&c);
printf("%.3f\n", (a+b+c)/3.0);
}

1-2 Input  Fahrenheit temperature f, output the centigrade degree c. Keep three decimal places. Hint: c=5(f-21)/9.

#include<stdio.h>
#include<math.h>
int main()
{
float f,c;
scanf("%f",&f);
c=*(f-)/;
printf("%.3f\n", c);
}

1-3 Input a positive integer n, output the value of 1+2+3+...+n.

Hint: Solve the problem rather than exercise programming. 

#include<stdio.h>
//#include<math.h>
int main()
{
int n,sum;
sum=;
scanf("%d", &n);
/*if(n == 1)
printf("1\n");
else */
{
for(int i=; i<=n; i++)
sum=sum+i;
printf("%d\n", sum);
} }

1-4 Input positive integer n (n<360), output the sin and cos value of n.

Hint: Use math functions.

#include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d", &n);
printf("%f %f\n", sin(n), cos(n));
}

1-5 A piece of clothes costs 95 yuan, and if the amount adds up to 300 yuan, it will have a 85% discount. Input  the sales number of clothes and output the money one should pay (yuan). Keep two places of decimal.

#include<stdio.h>
//#include<math.h>
int main()
{
int n;
float total;
scanf("%d", &n);
total=n*;
if (total<)
printf("%.2f\n", total);
else
printf("%.2f\n", total*0.85);
}

1-6 Input three lengths of a triangle (all possitive integers), and determine whether they can be three sides of a triangle. If so, output yes; otherwise, output not a triangle.

#include<stdio.h>
//#include<math.h>
int main()
{
int a,b,c;
scanf("%d%d%d", &a, &b, &c);
if ((a+b>c) && (a+c>b) && (b+c>c))
printf("yes");
else
printf("not a triangle");
return ;
}

1-7 Input a year and determine if it is a leap year. If yes, output yes; otherwise, output no.

#include<stdio.h>
//#include<math.h>
int main()
{
int n;
scanf("%d", &n);
if ((n% == ) || ((n% == ) && (n% != )))
printf("yes");
else
printf("no");
return ;
}

Q1 What's the minimum and maximum number of int integers? (give accurate number)

#include<stdio.h>
//#include<math.h>
int int_min()
{
int n=, i=;
while(n>=i)
{
n=i;
i--;
}
return n;
}
int int_max()
{
int n=, i=;
while(n <=i)
{
n=i;
i++;
}
return n;
} int main()
{
printf("%d\n", int_min());
printf("%d\n", int_max());
}

Q2 How actuate decimal places can double floats can be? Or, is it a right question?

#include<stdio.h>
//#include<math.h>
int main()
{
double i =1.0, j = 3.0;
printf("%.500f\n", i/j);
return ;
}

Ref. https://www.zhihu.com/question/36662447/answer/68630339

It shows 0.333333333333333310000000000...    (sixteen 3s ) so, there are maximum 16 decimal places in a double float. And  a double float can not acturately describe decimals.

Q3 What's the minimum and maximum positive integer of double floats? (no need to give accurate numbers)

(I don't know...)

Ref. http://blog.csdn.net/architect19/article/details/8551145

http://www.faceye.net/search/87209.html

Not working through...

Q4 What's the precedence of these logical operators, "&&", "||", and "!" ? How do you interpret a&&b||c ?

"&&" and "||"at the same precedence level, and are operated from left to right.

#include<stdio.h>
//#include<math.h>
int main()
{
int a=, b=,c=;
printf("%d", b&&c||a);
return ;
}

It shows 1.

"!" has higher priority than "&&" and "||" .

#include<stdio.h>
//#include<math.h>
int main()
{
int a=, b=,c=;
printf("%d", !b&&c||a);
return ;
}

It shows 1.

#include<stdio.h>
//#include<math.h>
int main()
{
int a=, b=,c=;
printf("%d", !(b&&c||a));
return ;
}

It shows 0.

Q5 What's the accurate meaning of if(a) if(b) x++; else y++? The else matches which if? Any accturate way to express the match?

The esle matches the second if.

#include<stdio.h>
int main()
{
int a, b,x, y;
if(a){
if (b)
x++;
else
y++;
}
return ;
}

Use braces to enclose a series of codes following if(a).

Ch1. Intro to Programming的更多相关文章

  1. The Go Programming Language. Notes.

    Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose End ...

  2. <转载>国外程序员推荐的免费编程书籍资源

    一.George Stocker 提供了一大串,分类如下: How to Design Programs: An Introduction to Computing and Programming 2 ...

  3. 转:Google技术开发指南:给大学生自学的建议

    原文来自于:http://blog.jobbole.com/80621/ 技术开发指南 想要成为成功的软件工程师,必须拥有坚实的计算机科学的基础.本指南针对大学生,给出一条自学途径,让学生以科班和非科 ...

  4. [转]ORACLE递归查询

    转自:http://www.oracle.com/technetwork/cn/articles/hartley-recursive-086819-zhs.html 递归数据库处理,也称为材料清单 或 ...

  5. [日常] Go语言圣经-匿名函数习题

    Go语言圣经-匿名函数1.拥有函数名的函数只能在包级语法块中被声明,通过函数字面量(function literal),我们可绕过这一限制,在任何表达式中表示一个函数值2.通过这种方式定义的函数可以访 ...

  6. Github上的1000多本免费电子书重磅来袭!

    Github上的1000多本免费电子书重磅来袭!   以前 StackOverFlow 也给出了一个免费电子书列表,现在在Github上可以看到时刻保持更新的列表了. 瞥一眼下面的书籍分类目录,你就能 ...

  7. Google Careers 程序员必修课

    quote from : https://www.google.com/about/careers/students/guide-to-technical-development.html Techn ...

  8. Github 的一个免费编程书籍列表

    Index Ada Agda Alef Android APL Arduino ASP.NET MVC Assembly Language Non-X86 AutoHotkey Autotools A ...

  9. 世界名校网络课程大盘点,美国大学CS专业十三大研究方向,世界50所知名大学提供开放课程

    世界名校网络课程大盘点   加州大学伯克利分校http://webcast.berkeley.edu/ 加州大学伯克利分校与斯坦福大学. 麻省理工学院等一同被誉为美国工程科技界的学术 领袖,其常年位居 ...

随机推荐

  1. JSSDK微信自定义分享

    背景:15年之前的微信分享只需要加入一段js就可以实现.后来微信官方全部禁止了.现在的微信分享全部得使用jssdk. 一.分享功能: 在微信内(必须在微信里)打开网站页面,分享给朋友或者分享到朋友圈时 ...

  2. 《算法4》读书笔记 1.4 - 算法分析(Analysis of Algorithm)

    --------------------------- First priority is to make you code ** CLEAR and CORRECT, but PERFORMANCE ...

  3. git的使用及常用命令(二)

    一,把文件放在版本库中 执行  git add XXX文件名 在执行 git commit -m ‘提交注释' 查看状态 git status 如果没有改变文件,nothing to comment ...

  4. 各种API总结大全 JAVA、HTML、HTML5等等

    本文章,发现新的API会进行更新,如果你们觉得有新的版本或者拥有新的,也可以发有邮箱到"zenglei8732@163.com"当中,本人会在12小时内更新,非常感谢!!! HTM ...

  5. WPF 杂谈——入门介绍

    对于WPF的技术笔者是又爱又恨.现在WPF的市场并不是很锦气.如果以WPF来吃饭的话,只怕会饿死在街头.同时现在向面WEB开发更是如火冲天.所以如果是新生的话,最好不要以WPF为主.做为选择性来学习一 ...

  6. UBIFS文件系统介绍

    1.  引言 UBIFS,Unsorted Block Image File System,无排序区块图像文件系统.它是用于固态硬盘存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一 ...

  7. 如何在 ASP.NET Core 中发送邮件

    前言 我们知道目前 .NET Core 还不支持 SMTP 协议,当我么在使用到发送邮件功能的时候,需要借助于一些第三方组件来达到目的,今天给大家介绍两款开源的邮件发送组件,它们分别是 MailKit ...

  8. 蓝桥杯-兰顿蚂蚁-java

    /* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2016, 广州科技贸易职业学院信息工程系学生 * All rights reserved. * 文件名称: ...

  9. OSI七层模型学习笔记

    1.简介 什么是OSI模型呢? OSI模型全名Open System InterConnect 即开放式系统互联,是国际标准化组织(ISO)提出的一个试图使各种计算机在世界范围内互连为网络的标准框架, ...

  10. 安装Vmware 以及 Vmware 中安装Ubuntu 以及其中问题?

    在vmware中安装ubuntu 过程中 安装窗口太小,无法继续下一步? 按住alt键,用鼠标拖动linux的安装窗体,向上移动就能看到下面的确定按钮. 如何安装Vmware-tools? 1.VM菜 ...