高数真难QAQ............昨天忘记一天编程,明天要好好补回来
C Prime Plus 5章的知识点差不多都是翁恺老师将过的知识点
学习,学习,学习!!!
#include<stdio.h>
#define SQUARES 64 //棋盘中的方格数目
#define SEC_PER_MIN 60
int main()
{
const double CROP =2E16; //世界小麦年产谷粒数
double current,total;
int count=1;
printf("square grains total fraction of\n");
printf(" added grains world total\n");
total=current=1.0;
printf("%4d %13.2e %12.2e %12.2e\n",count,current,total,total/CROP);
while(count<SQUARES)
{
count=count+1;
current=2.0*current;
total+=current;
printf("%4d %13.2e %12.2e %12.2e\n",count,current,total,total/CROP);
}
printf("That's all\n\n");
printf("integer division: 5/4 is %d\n",5/4 );
printf("integer division: 6/3 is %d\n",6/3 );
printf("integer division: 7/4 is %d\n",7/4 );
printf("floating division: 7./4. is %1.2f\n",7./4.);
printf("mixed division: 7./4 is %1.2f\n",7./4 );
int sec,min,left;
printf("Convert seconds to minutes and seconds !\n");
printf("Enter the number of seconds(<=0 to quit):\n");
scanf("%d",&sec); //读取秒数
while(sec>0)
{
min=sec/SEC_PER_MIN; //截断的分钟数
left=sec%SEC_PER_MIN; //剩下的秒数
printf("%d seconds is %d minutes , %d seconds.\n",sec,min,left);
printf("Enter next value (<=0 to quit):\n");
scanf("%d",&sec);
}
printf("Done!\n\n");
long num;
long sum=0L;
int status;
printf("Please enter an integer to be summed");
printf("(q to quit):");
status=scanf("%ld",&num);
while(status==1)
{
sum+=num;
printf("Please enter next integer (q to quit):");
status=scanf("%ld",&num);
}
printf("Those integers sum to %ld.\n");
}