C语言实用算法系列之冒泡排序、sizeof与strlen的区别
生活随笔
收集整理的這篇文章主要介紹了
C语言实用算法系列之冒泡排序、sizeof与strlen的区别
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
直接看代碼
#include <stdio.h> #include<string.h> int main() {//char s[10] = { 98,68,55,'-','x','y' }; // sizeof=10 strlen =6//char s[10] = "abc%78"; // 從常量區拷貝賦值,sizeof=10 strlen =6//char s[] = { 'a','b','c','\0' }; // sizeof=4 strlen=3//char s[] = "abcd%3"; // sizeof=7 strlen=6printf("sizeof(s)=%d\n", sizeof(s));printf("strlen(s)=%d\n", strlen(s));int a[10] = { 31,40,21,23,6,9,25,11,3,8 };//冒泡排序int i = 0;while (i < 9){int j = 0;while (j < 9-i) // 0...8{if (a[j] > a[j + 1]){int t = a[j];a[j] = a[j + 1];a[j + 1] = t;}++j;}++i;}i = 0;while (i < 10)printf("%d ", a[i++]); } 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的C语言实用算法系列之冒泡排序、sizeof与strlen的区别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机所属地(手机所属地查)
- 下一篇: 电脑快捷键弹出登录界面(快速回到登录界面