C语言学习记录3
2018-03-27 09:54
190 查看
#include <stdio.h> int main(void) { char beep=7; printf("%c",beep); printf("startled by the sudden sound,sally shouted,\n"); printf("\"by the ggreat pumpkin,wahat was that!\""); }
%d int %ld long int %c char %f float %u unsigned %hd short %lf double %x 以16进制输出int or long int or short int %o 八进制输出 %s 字符串
#include <stdio.h> int main(void) { float a=64.25; printf("enter a floating-point value:64.25\n"); printf("exponential notation: %e\n",a); printf("fixed-point notation:%f\n",a); return 0; }
#include <stdio.h> int main(void) { float a; printf("enter a floating-point value:"); scanf("%f",&a); printf("exponential notation: %e\n",a); printf("fixed-point notation:%f\n",a); return 0; }
#include <stdio.h>
#define ADJUST 7.31
int main()
{
const double SCALE=0.333; //const 常量
double shoe,foot;
printf("Shoe size (men's) foot length\n");
shoe=3.0;
while (shoe<18.5) //while循环开始
{ /*块开始*/
foot=SCALE*shoe+ADJUST;
printf("%10.lf %15.2f inches\n",shoe,foot);
shoe=shoe+1.0;
} //块结束
printf("if the shoe fits,wear it.\n");
return 0;
}
#include <stdio.h>
#define ADJUST 7.31
int main()
{
int a=0;
int b;
while (a<10)
{
a=a+1;
b=a*a;
printf("%4d %6d\n",a,b);
}
return 0;
}
#include <stdio.h>
#define SQUARES 10
int main()
{
const double CROP=2E16;
double current,total;
int count=1;
printf("square grains total ");
printf(" fraction of \n");
printf(" added grains ");
printf(" world total\n");
total=current=1.0;
printf("%4d %13d %12.2e %12.2e\n",count,current,total,total/CROP);
while (count<SQUARES)
{
count=count+1;
current=2.0*current;
total=total+current;
printf("%4d %13.2e %12.2e %12.2e\n",count,current,total,total/CROP);
}
printf("That's all.\n");
getchar();
return 0;
}
#include <stdio.h>
#define sec_min 60
int main()
{
int min,sec,left;
printf("convert second to minute and second\n");
printf("please input the seconds:\n");
scanf("%d",&sec);
while (sec>0)
{
min=sec/sec_min;
left=sec%sec_min;
printf("%d seconds is %d minutes and %d seconds\n",sec,min,left);
printf("please input another seconds:\n");
scanf("%d",&sec);
}
printf("Done!\n");
return 0;
}
相关文章推荐
- C语言学习记录之一
- 链队列(C语言实现)学习记录
- 双向链表(C语言实现)学习记录
- C语言学习记录 内存四区之全局区
- C语言学习重点记录(一)
- IOS开发学习记录第5天之C语言学习
- 开始学习C语言C++在这里记录自己的成长。简单的两变量交换问题
- C语言深度剖析学习错误点记录
- Huffman学习记录 c语言
- C语言学习记录4
- IOS开发学习记录--C语言中的printf函数详解&转义符
- IOS开发学习记录第4天之C语言学习
- 记录我的数据结构(C语言)学习历程(2017年3月30号开始):
- C语言学习记录2
- C语言学习记录4
- 栈(C语言实现)学习记录
- C语言学习记录2
- 本篇记录c语言中error的用法,学习中后面会继续更新
- C语言学习记录之二
- 黑马程序员--------------------------------------------C语言学习记录五