当前位置:网站首页>C语言简单实例 1
C语言简单实例 1
2022-07-28 18:11:00 【美好生活体验官】
**C语言学习**
学习目标:
Visual C++6.0/Visual Studio
1. 顺序、选择、循环结构……
2. 区分一些常见错误,比如说:中英文符号、大小写、‘=’与‘==’区别等
3. 熟练运用 数组、函数、指针、链表、结构体、文件和数组
4. 管理系统、简单小游戏、聊天室…
简单实例
计算机语言4个阶段:机器语言→汇编语言→高级语言→面向对象的高级语言
常用数制:二进制、八进制、十进制、十六进制
数据的三种表示方法:原码、反码、补码
程序设计思想:算法
算法的特点:有穷性、确定性、有效性、输入/出、
算法的描述方法:自然语言、伪代码、流程图、N-S图等
衡量算法优劣:正确性、可读性、健壮性、时间复杂度与空间复杂度
转义字符:
- 第一个程序
#include <stdio.h>
{
printf("Hello World!\n");
return 0;
}
2. 自动类型转换
不同类型的数值进行运算时,系统会自动将级别低的类型转换成级别高的类型,运算结果和级别最高的保持一致。
#include <stdio.h>
int main()
{
int a=3;
float b;
b=a/3;
printf("%f\n",b);
return 0;
}
3. 强制类型转换
语法格式:(类型名)表达式
#include <stdio.h>
/*将浮点型数据强制转换成整型*/
int main()
{
float x=3.5;
int a;
a=(int)x;
printf("%f %d\n",x,a);
return 0;
}
4. 字符、字符串形式输出
#include <stdio.h>
int main()
{
char ch1;
int ch2;
char c[]="ab";
ch1='A';
ch2=98;
printf("%c %c %s\n",ch1,ch2,c);
return 0;
}
5. ++/- -运算
#include <stdio.h>
int main()/*加减一样*/
{
int a=3,A=3,b,c;
b=a++;/*先把a赋值给b,再自加*/
c=++A;/*先A自加,再把A赋值给b*/
printf("%d %d\n",b,c);
printf("%d\n",a);//a自加变成4
return 0;
}
边栏推荐
- C language functions and pointers
- Richpedia: A Large-Scale, Comprehensive Multi-Modal Knowledge Graph
- Andorid system layout, values, drawable adaptation
- C+ + core programming
- [C language] Gobang game [array and function]
- Implementation of memmove in C language
- Item exception handling in SSM
- Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
- Basic knowledge of C language
- JS batch add event listening onclick this event delegate target currenttarget onmouseenter OnMouseOver
猜你喜欢
JVM(二十四) -- 性能监控与调优(五) -- 分析GC日志
[C language] initial C language reflection and summary
[NPP installation plug-in]
“中国网事·感动2022”二季度网络感动人物评选结果揭晓
English translation Italian - batch English translation Italian tools free of charge
Can China make a breakthrough in the future development of the meta universe and occupy the highland?
Cdga | how can the industrial Internet industry do a good job in data governance?
English translation Portuguese - batch English conversion Portuguese - free translation and conversion of various languages
私有化部署的即时通讯平台,为企业移动业务安全保驾护航
Longest Palindromic Substring
随机推荐
长轮询,iframe和sse三种web消息实时推送demo实践
Basic mathematical knowledge (update)
1、 Relationship among CPU, memory and hard disk
Digital filter design matlab
Basic usage of docker
Merge sort template
最大交换[贪心思想&单调栈实现]
Sequential linear table - practice in class
C language - data type
C语言数据 3(1)
Quick sort template
JS preventdefault() keyboard input limit onmousewheel stoppropagation stop event propagation
83. (cesium home) how the cesium example works
[C language] summary of methods for solving the greatest common divisor
Store and guarantee rancher data based on Minio objects
[C language] advanced pointer exercise 1
Why is there no log output in the telnet login interface?
What is the variance?
9. Pointer of C language (5) how many bytes does the pointer variable occupy
[experiment sharing] CCIE BGP reflector experiment