当前位置:网站首页>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;
}

边栏推荐
- In the second half of 2022, the system integration project management engineer certification starts on August 20
- [C language] initial C language reflection and summary
- ssm中项目异常处理
- Implementation of strcat in C language
- Implementation of memcpy in C language
- Usage of const and assert
- JS preventdefault() keyboard input limit onmousewheel stoppropagation stop event propagation
- 9. Pointer of C language (4) pointer and one-dimensional array, pointer operation
- 河北:稳粮扩豆助力粮油生产提质增效
- Basic knowledge of communication network 01
猜你喜欢

Intermediate soft test (system integration project management engineer) high frequency test site

Store and guarantee rancher data based on Minio objects

4. Const and difine and the problem of initializing arrays with const and define

为什么客户支持对SaaS公司很重要?

Article translation software - batch free translation software supports major translation interfaces

English translation Portuguese - batch English conversion Portuguese - free translation and conversion of various languages
![最大交换[贪心思想&单调栈实现]](/img/ad/8f0914f23648f37e1d1ce69086fd2e.png)
最大交换[贪心思想&单调栈实现]

adb remount of the / superblock failed: Permission denied

Kubeedge releases white paper on cloud native edge computing threat model and security protection technology

C语言数据 3(2)
随机推荐
Simple use of robobrowser
Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
Machine learning -- model evaluation, selection and verification
私有化部署的即时通讯平台,为企业移动业务安全保驾护航
plt. What does it mean when linestyle, marker, color equals none in plot()
C语言数据 3(1)
进制及数的表示 2
Article translation software - batch free translation software supports major translation interfaces
C+ + core programming
4. Const and difine and the problem of initializing arrays with const and define
【CodeForces】Educational Codeforces Round 132 (Rated for Div. 2)
English translation Arabic - batch English translation Arabic tools free of charge
WPF--实现WebSocket服务端
Implementation of memcpy in C language
JS batch add event listening onclick this event delegate target currenttarget onmouseenter OnMouseOver
Solve the kangaroo crossing problem (DP)
BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
Const pointer of C language and parameter passing of main function
2022年下半年系统集成项目管理工程师认证8月20日开班
9. Pointer of C language (1) what is pointer and how to define pointer variables