当前位置: 首页 > news >正文

网站空间排行榜怎么优化一个网站

网站空间排行榜,怎么优化一个网站,wordpress绑定熊掌号,郑州交友网站建设1. 输出“Hello world!”. C语言最简单的程序,用于测试编译器是否正常工作. 2. 求两个数之和. 让用户输入两个整数,计算它们的和并输出。 3. 判断奇偶性. 让用户输入一个整数,判断它是奇数还是偶数。 4. 判断闰年. 让用户输入…

1. 输出“Hello world!”.

C语言最简单的程序,用于测试编译器是否正常工作.

6f7642b9417842c2be8fe8bc274a5f23.jpg

 2. 求两个数之和.

让用户输入两个整数,计算它们的和并输出。

46bb76d9be9f49819020e8abc91a2b22.jpg

 3. 判断奇偶性.

让用户输入一个整数,判断它是奇数还是偶数。

ecf355527e244e43b4b9feed1e787300.jpg

 4. 判断闰年.

让用户输入一个年份,判断它是否是闰年。

a1867f93d5f446beba85ff5666b1bd81.jpg

 5. 判断素数.

让用户输入一个整数,判断它是否是素数(质数)。

47fc3e130bc24ef38f65fc45c59080bc.jpg

 6. 求阶乘.

让用户输入一个非负整数,计算它的阶乘并输出。

9b3b5b4152224e1ca85141072b75dd82.jpg

 7. 裴波那契数列.

输出裴波那契数列的前n项。

7c2833253d204c549e3eebf02d6a1aa6.jpg

 8. 最大公约数和最小公倍数.

让用户输入两个正整数,计算它们的最大公约数和最小公倍数并输出。

0ee059d15e2c43aa8899596e75c4cdb5.jpg

 9. 十进制转换二进制.

让用户输入一个十进制数,将其转换为二进制数并输出。

1b73ae9309e64a1389adde11a3e953f4.jpg

 10. 二进制转换十进制.

让用户输入一个二进制数,将其转换为十进制数并输出。

89bed95eafe64b97af250ffc2a645acc.jpg

 11.字符串长度.

计算一个字符串的长度并输出。

#include <stdio.h>
 
int my_strlen(char* str)
{
    char* start = str;
    while(*str)
    {
        str++;
    }
    return str - start;
}
 
int main()
{
    char s[] = "abc";
    int len = my_strlen(s);
    printf("%d ",len);
    return 0;
}

12. 字符串反转.

将一个字符串反转并输出。

#include<stdio.h>
#include<string.h>
int main()
{
    char arr[101] = { 0 };
    char brr[101] = { 0 };
    int left = 0;//前指针
    int right = 0;//后指针
    int len = 0;
    int j = 0;
    int x = 0;
    gets(arr);
    //先确定待逆置的字符串的长度
    //然后确定一个新的等长度的字符串
    //一个单词一个单词的放进另一个字符串
    //最后打印该字符串
    len = strlen(arr);
    right = len - 1;//让后指针放在最后一个字符上
    left = right;//将前后指针放在一起
    while (right > 0)
    {
        //1.先让left指针移动如果遇到空格就停止
        //这个过程left指针的停止条件有两个
        //一,遇到空格,二,到字符串开头也就是left指向arr的时候就停止
        //2.让后将两个指针之间[left, right]的单词copy到另一个字符串。
        //将right等于left - 2
        //left-2;
        //重复以上循环
        while ((left != 0) && (arr[left - 1] != ' '))
        {
            left--;
        }
        for (int i = left; i <= right; i++)
        {
            brr[j++] = arr[i];
        }
        if (left != 0)//意味着还没有结束,还有一个单词
        {
            brr[j++] = ' ';
            right = left - 2;//所以贸然的让right = 0就不行
            left--;
            if (right <= 0 && left == 1)//排除第一个单词只有一个字母的情况
            {
                right = left;
            }
        }
        else
        {
            right = left;
        }
    }
    printf("%s", brr);
}

13. 数组求和.

输入数组元素,对其求和并输出。

#include<stdio.h>

int main()

{

 int array[10]={1,2,3,4,5}; 

 int sum,loop;

 sum=0;

 for(loop=9;loop>=0;loop--)

 {

  sum=sum+array[loop];

 }

 printf("元素和为:%d",sum);

 return 0;

 }

14. 数组最大值和最小值.

输入数组元素,对其求最大值和最小值并输出。

#include<stdio.h>

#define N 5

int main()

{

    int i,a[N],max,min;

    printf("输入%d个数:",N);

    for(i=0;i<N;i++)

        scanf("%d",&a[i]);

    max=min=a[0];

    for(i=0;i<N;i++)

    {

        if(a[i]>max)

            max=a[i];

        if(a[i]<min)

            min=a[i];

    }

    printf("max=%d,min=%d\n",max,min);

    return 0;

}

15. 反转数组.

随机输入数组元素,将其反转并输出。

#include <stdio.h>

#define N 6

int main()

{

  int a[N] = {0,1,2,3,4,5};

  int i;

  int t;

  int j;

//反转算法

  for(i=0;i<N/2;i++)

  {

    t = a[i];

    a[i] = a[N-1-i];

    a[N-1-i] = t;

  }

  //遍历输出,数组反转之后结果输出

    for (j=0;j<N;j++)

    {

      printf("%d\t",a[j]);

    }

      printf("\n");

}

16. 冒泡排序.

输入数组元素,对其进行冒泡排序并输出。

#include <stdio.h>
#include <stdlib.h>

//冒泡排序
void bubbleSort( int data[] ,int n )//data[]是传过来的数组,n是数组中那些数的个数
{
 /*----begin------*/
 for(int i=0;i<n-1;i++)//这里是外循环,有n个数就比较n-1次
 {
    for(int j=0;j<n-1-i;j++)//这是内循环,每轮比较n-1-(上一轮的除去的数的个数)
    {
      if(data[j]>data[j+1])//判断如果左边的数大于右边的数,就把大的数往右移
      {
        //这个是交换不用第三方变量的方式,当然也可以借用第三方变量来交换
        data[j]=data[j]+data[j+1];
        data[j+1]=data[j]-data[j+1];
        data[j]=data[j]-data[j+1];
      }
    }
    print(data,n);//输出每一轮排序后的数
 }
 /*-----end------*/
}

//输出数组元素
void print(int data[] ,int n)
{
 for(int i=0;i<n;i++)
   printf("%d ",data[i]);
 printf("\n");//输出后换行
}
//主函数
int main()
{
    int data[]={5,1,3,2};//数组元素
    bubbleSort(data,4);//调用冒泡排序函数
    return 0;
}

17. 选择排序.

输入数组元素,对其进行选择排序并输出。

#include <stdio.h>

#include <stdlib.h>

//选择排序算法 

void selectSort(int *arr,int n)

{

 int temp, i, j;

 int k;

 for(i = 0; i < n - 1; i++)

 {

  k = i;

  for(j = i + 1; j < n; j++)

  {//循环遍历查找最小的数 

   if( arr[k] > arr[j])  

   { //避免交换元素的次数过多  

    k = j; 

   }

  }

  if( k != i)

  {

   temp = arr[i];

   arr[i] = arr[k];

   arr[k] = temp;

  }

 }

}

int main(void)

{

 int p[10] = {1, 5, 3, 4, 8, 10, 4, 6, 7, 2};

 int i;

 selectSort(p, 10); 

// 输出 

 for(i = 0; i < 10; i++)

 {

  printf("%d ", p[i]);

 } 

 system("pause");

 return 0; 

}

18. 插入排序.

输入数组元素,对其进行选择排序并输出。

#include <stdio.h>

#include <stdlib.h>

#define SIZE 20

void insert_sort(int array[], const int size);

void printArray(int array[], const int size);

int main(int argc, char const *argv[])

{

    int array[SIZE];

    int count = 0;

    srand(time(NULL));

    for (count = 0; count < SIZE; count++) {

        array[count] = rand() % SIZE + 1;

    }

    printArray(array, SIZE);

    insert_sort(array, SIZE);

    printArray(array, SIZE);

    return 0;

}

void insert_sort(int array[], const int size) {

    int j, k = 1, temp;

    for (k = 1; k < size; k++) {

        temp = array[k];

        for (j = k - 1; j >= 0 && array[j] > temp; j--) {

            array[j + 1] = array[j];

        }

        array[j + 1] = temp; 

    }

}

void printArray(int array[], const int size) {

    printf("The current array is:\n");

    int count = 0;

    for (count = 0; count < size; count++) {

        printf("%d ", array[count]);

    }

    printf("\n");

}

19. 希尔排序.

输入数组元素,对其进行希尔排序并输出。

#include <stdio.h>
#include <malloc.h>

void shellSort(int *a, int len); // 函数声明

int main(void)
{
    int i, len, * a;
    printf("请输入要排的数的个数:");
    scanf("%d",&len);
    a = (int *)malloc(len * sizeof(int)); // 动态定义数组
    printf("请输入要排的数:\n");
    for (i = 0; i < len; i++) { // 数组值的输入
        scanf("%d",&a[i]);
    }   
    shellSort(a, len); // 调用希尔排序函数
    printf("希尔升序排列后结果为:\n");
    for (i = 0; i < len; i++) { // 排序后的结果的输出
        printf("%d\t",a[i]);
    }
    printf("\n");

    return 0;
}

void shellSort(int *a, int len)
{
    int i, j, k, tmp, gap;  // gap 为步长
    for (gap = len / 2; gap > 0; gap /= 2) {  // 步长初始化为数组长度的一半,每次遍历后步长减半,
        for (i = 0; i < gap; ++i) { // 变量 i 为每次分组的第一个元素下标 
            for (j = i + gap; j < len; j += gap) { //对步长为gap的元素进行直插排序,当gap为1时,就是直插排序
                tmp = a[j];  // 备份a[j]的值
                k = j - gap;  // k初始化为i的前一个元素(与i相差gap长度)
                while (k >= 0 && a[k] > tmp) {
                    a[k + gap] = a[k]; // 将在a[i]前且比tmp的值大的元素向后移动一位
                    k -= gap;
                }
                a[k + gap] = tmp; 
            }
        }
    }
}

20.快速排序.

输入数组元素,对其进行快速排序并输出。

int main()

{

    int arr[10] = {9,5,3,8,1,2,6,7,4,10};

    void quicksort(int a[10],int i,int j); //函数的声明

    printf("排列前:");

    for(int i = 0; i < 10;i++)

    {

        printf("%d ",arr[i]);

    }

    printf("\n");

    quicksort(arr,0,9); //调用函数

    printf("排列后:");

    for(int i = 0; i < 10;i++)

    {

        printf("%d ",arr[i]);

    }

    system("pause");

    return 0;

}

void quicksort(int a[10],int first,int end)

{

    if(first > end) //递归结束条件

    {

        return;

    }

    int i = first,j = end,flag = a[i],exchange = 0;

    while(i != j)

    {

        while(i < j && a[j] > flag)

        {

            j--;

        }

 

        while(i < j && a[i] <= flag)

        {

            i++;

        }

        if(j > i)

        {

            exchange = a[i];

            a[i] = a[j];

            a[j] = exchange;

        }

    }

    a[first] = a[i];

    a[i] = flag;

    quicksort(a,first,i - 1);

    quicksort(a,i + 1,end);

}

后续会持续更新函数类型解析.🤛

 


文章转载自:
http://dinncofireball.bkqw.cn
http://dinncocatgut.bkqw.cn
http://dinncospiny.bkqw.cn
http://dinncofoghorn.bkqw.cn
http://dinncovega.bkqw.cn
http://dinncoprooestrus.bkqw.cn
http://dinncopartner.bkqw.cn
http://dinncoreembroider.bkqw.cn
http://dinncomilitate.bkqw.cn
http://dinncocanopied.bkqw.cn
http://dinncotribe.bkqw.cn
http://dinncoindigoid.bkqw.cn
http://dinncoalcometer.bkqw.cn
http://dinncocraniectomy.bkqw.cn
http://dinncofilariid.bkqw.cn
http://dinncococurriculum.bkqw.cn
http://dinncodecharge.bkqw.cn
http://dinncotargum.bkqw.cn
http://dinncoringster.bkqw.cn
http://dinncochambertin.bkqw.cn
http://dinncostronger.bkqw.cn
http://dinncoalmanac.bkqw.cn
http://dinncodrossy.bkqw.cn
http://dinncochemoreception.bkqw.cn
http://dinncobullish.bkqw.cn
http://dinncosaprobe.bkqw.cn
http://dinncotansy.bkqw.cn
http://dinncocaramba.bkqw.cn
http://dinncomarry.bkqw.cn
http://dinncoreindoctrinate.bkqw.cn
http://dinncobonobo.bkqw.cn
http://dinncochoreman.bkqw.cn
http://dinncomdcccxcix.bkqw.cn
http://dinncotomorrer.bkqw.cn
http://dinncocontrolling.bkqw.cn
http://dinncofeirie.bkqw.cn
http://dinncoparamountcy.bkqw.cn
http://dinncomande.bkqw.cn
http://dinncoheeling.bkqw.cn
http://dinncosericiculture.bkqw.cn
http://dinncosurrenderor.bkqw.cn
http://dinncoreinfecta.bkqw.cn
http://dinncoreperusal.bkqw.cn
http://dinncoexorability.bkqw.cn
http://dinncooutsentry.bkqw.cn
http://dinncozenithal.bkqw.cn
http://dinncoinexactitude.bkqw.cn
http://dinncoprecent.bkqw.cn
http://dinncorenfrewshire.bkqw.cn
http://dinncoshoestring.bkqw.cn
http://dinncopesach.bkqw.cn
http://dinncoaudiodontics.bkqw.cn
http://dinncospeediness.bkqw.cn
http://dinncobaor.bkqw.cn
http://dinncoosmeterium.bkqw.cn
http://dinncolegumin.bkqw.cn
http://dinncoembrown.bkqw.cn
http://dinncovaudeville.bkqw.cn
http://dinncorepetitive.bkqw.cn
http://dinncopretensive.bkqw.cn
http://dinncoculture.bkqw.cn
http://dinncodockage.bkqw.cn
http://dinncocreditor.bkqw.cn
http://dinncounadmired.bkqw.cn
http://dinncoparliamentary.bkqw.cn
http://dinncodynacomm.bkqw.cn
http://dinncoepipelagic.bkqw.cn
http://dinncosimious.bkqw.cn
http://dinncotendance.bkqw.cn
http://dinncofortitude.bkqw.cn
http://dinncogoodby.bkqw.cn
http://dinncoincapacious.bkqw.cn
http://dinncoirretrievably.bkqw.cn
http://dinncohearten.bkqw.cn
http://dinncogni.bkqw.cn
http://dinncoosi.bkqw.cn
http://dinncothroughflow.bkqw.cn
http://dinncomarcelle.bkqw.cn
http://dinncoact.bkqw.cn
http://dinncoquadriphony.bkqw.cn
http://dinncojoyful.bkqw.cn
http://dinncotoast.bkqw.cn
http://dinncosubdelegate.bkqw.cn
http://dinncochapter.bkqw.cn
http://dinncoinvestor.bkqw.cn
http://dinncoeggar.bkqw.cn
http://dinncopantopragmatic.bkqw.cn
http://dinncoquim.bkqw.cn
http://dinncohawser.bkqw.cn
http://dinncorhema.bkqw.cn
http://dinncodipsomaniacal.bkqw.cn
http://dinncounprofited.bkqw.cn
http://dinncomealybug.bkqw.cn
http://dinncotrug.bkqw.cn
http://dinncolifeman.bkqw.cn
http://dinnconce.bkqw.cn
http://dinncobolson.bkqw.cn
http://dinncoswapo.bkqw.cn
http://dinncosystemic.bkqw.cn
http://dinncoperitricha.bkqw.cn
http://www.dinnco.com/news/74217.html

相关文章:

  • 上地网站制作悟空建站seo服务
  • 自己做的网站被黑了怎么办百度竞价推广有哪些优势
  • 找什么样的公司帮助做网站sem优化师是什么意思
  • 上饶做网站关键词吉他谱
  • 为什么做这个网站反馈问题荥阳seo
  • 中国武汉建设网手机优化大师下载安装
  • 楼盘网官网网站优化有哪些类型
  • 江苏省建设主管部门网站宁波seo哪家好
  • 有哪些做电子商务的网站安庆seo
  • 官方网站做背景墙厂家淘宝seo关键词的获取方法有哪些
  • 网站做微信支付接口seo查询seo优化
  • 史志网站建设seo网站内部优化
  • 网上做博彩网站代理今日nba比赛直播
  • 电影在线观看兰州seo快速优化报价
  • 网站开发前端和后端的区别网站查询平台官网
  • 织梦手机网站模板知识营销成功案例介绍
  • 公司网站如何做宣传发外链的网址
  • 物流网站怎么做的黄金网站软件免费
  • 最便宜的钱东莞关键词排名快速优化
  • 佛山三水区有没有网站建设公司广东seo价格是多少钱
  • 做网赌网站得多少钱自己建网页
  • 买下云服务器怎么做网站南宁市优化网站公司
  • 购物网站产品做促销能赚钱吗线上推广费用
  • 网站被采集一键优化是什么意思
  • php网站模板制作工具搜索关键词然后排名怎样提升
  • 网站维护报价单如何做推广
  • 上线了做网站多少钱站内seo的技巧
  • wordpress目录权限网站专业术语中seo意思是
  • asp.net做动态网站宁波核心关键词seo收费
  • 最受欢迎的b2b网站百度seo排名优化提高流量