1#include<stdio.h>
2intmain()
3{
4floata,b,s;
5a=1.0/2;
6b=1.0/3;
7s=a+b;
8printf("s=%f\n",s);
9return0;
10}
11
12
13
14
15/*計(jì)算兩位數(shù)整數(shù)各位數(shù)字之和*/
16#include<stdio.h>
17#include<math.h>
18intmain()
19{
20inttwoNum;
21printf("請(qǐng)輸入一位兩位整數(shù):\n");
22scanf("%d",&twoNum);
23
24intshiwei=twoNum/10;
25intgewei=twoNum%10;
26printf("%d的個(gè)位與十位相加的和為:%d",twoNum,shiwei+gewei);
27printf("\n");
28return0;
29
30}
31
32
33
34/*計(jì)算三位數(shù)整數(shù)各位數(shù)字之和*/
35#include<stdio.h>
36#include<math.h>
37intmain()
38{
39intthreeNum;//定義一個(gè)整型變量threeNum
40printf("請(qǐng)輸入一位三位整數(shù):\n");
41scanf("%d",&threeNum);//通過scanf()函數(shù),從鍵盤輸入一個(gè)三位數(shù)給threeNum
42
43intbaiwei=threeNum/100;//定義一個(gè)整型變量baiwei,并將threeNum/100的值賦給baiwei,因?yàn)閕nt型為整數(shù),所以threeNum/100的值為整數(shù)(不是四舍五入,直接取整數(shù)值)
44
45//定義一個(gè)整型變量shiwei,并用兩種不同的方法給shiwei賦值
46/