大学程序实验.C语言.数据类型入门.认识数据类型
- 0 目录
- 1 数据类型入门汇总
- 1.1 认识数据类型
- 1.1.1 题目
- 1.1.2 源码
- 1.1.3 下载
- 2 下一章
0 目录
1 数据类型入门汇总
1.1 认识数据类型
1.1.1 题目
定义不同数据类型(int,char,long,unsigned int,float,double),并尝试不同的输出类型,并找出其规律
1.1.2 源码
// c91.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
int main()
{
int a=5,b=7;
char c='a';
long n=1234567L;
unsigned int u=4294967295U;
float x=677.8564,y=-789.124F;
double w=677.8564,v=-789.124;
//
printf("%d%d\n",a,b);
printf("%3d%3d\n",a,b);
printf("%f,%f\n",x,y);
printf("%-12f,%-12f\n",x,y);
printf("%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n",x,y,x,y,x,y);
printf("%1f,%1f\n",w,v);
printf("%121f,%121f\n",w,v);
printf("%8.21f,%8.21f%.41f,%41f,%31f,%31f\n",w,v,w,v,w,v);
printf("%c,%d,%o,%x\n",c,c,c,c);
printf("%1d,%1o,%x\n",n,n,n);
printf("%u,%o,%x,%d\n",u,u,u,u);
printf("%s,%5.3s\n","computer","computer");
return 0;
}
1.1.3 下载
链接地址: 1.1_c91.cpp
2 下一章
博客地址: