作者: 丿水木灬年华 | 来源:发表于2016-12-09 21:02 被阅读0次

    1    使用while循环实现九九乘法表

    #includeint main(int argc, char **argv)

    {

    int i=1;

    int j=1;

    while(i<10)

    {

    j=1;

    while(j<=i)

    {

    printf("%d*%d=%d",i,j,i*j);

    j++;

    }

    printf("\n");

    i++;

    }

    return 0;

    }

    .........................................................................................................................................................................................................................

    2  .for或者while实现打印等腰三角形,行数由用户输入

    #include

    main()

    {

    int i,j,k,n,t;

    printf("请输入行数\n");

    scanf("%d",&n);

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

    {

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

    {

    printf(" ");

    }

    for(k=1;k

    {

    printf("*");

    }

    for(t=1;t

    printf("*");

    printf("\n");

    }

    }

    ---------------------------------------------------------------------------------------------------------------

    3  写一个脚本,判断给定目录下的文件属性

    #!/bin/bash

    read -p "please input the file name:" file

    if [ ! -n "$file" ];

    then

    echo please input the file name please

    exit 0

    fi

    ls $file > /dev/null 2>&1

    if [ $? -eq 0 ]

    then

    echo file exist

    cp $file $file.bak

    vi $file

    else

    echo file not exist!

    fi

    相关文章

      网友评论

          本文标题:

          本文链接:https://www.haomeiwen.com/subject/zlrymttx.html