• 瞎打一波


    
    

    周次

    学习时间

    新编写代码行数

    博客量(篇)

    学到知识点

             

    第15周

    0.5h

     95

    1









    #include<stdio.h> #include "stdafx.h" #include"math.h" int search();//查找数组下标 void calc();//计算 int nums[5]; void sort(int nums); main() { int i; int nums[5]; // int index; // calc(); // index=search(); // printf("The you need number's index is :%d ",index); printf("Please enter the array's element : "); for (i = 0; i < 5; i++) scanf_s("%d",nums+i); printf("The array is : "); for (i = 0; i < 5; i++) printf(" %d ",*(nums+i)); sort(nums); getch(); return 0; } void sort(int *(nums)) { int i, j; int temp; for (i = 0; i <= 5; i++) { for (j = 0; j <= i-2; j++) { if (*(nums + j) > *(nums + j + 1)) { temp = nums[j]; nums[j] = nums[j+1]; nums[j+1] = temp; } } } printf(" The after sort array:"); for (i = 0; i < 5; i++) { printf(" %d ",*(nums+i)); } } int search() { int i; int searchnums; int searchindex=-1; int nums[5] = {0,5,12,6,32}; printf("Please enter the element you want to find "); scanf_s("%d", &searchnums); printf(" "); for (i = 0; i <= 5; i++) { if (searchnums == *(nums + i)) { searchindex = i; break; } } return searchindex; } void calc()//计算最小公倍数,最大公约数 { int i, j, num1, num2; printf("Please put two numbers for Find the least common multiple :"); scanf_s("%d%d", &num1, &num2); for (i = 1; i < num1*num2; i++) { if (i%num1 == 0 && i%num2 == 0) break; } for (j =num1+num2; j >1; j--) { if (num1 % j == 0 && num2%j == 0) break; } printf("The %d and %d 's least common multiple is %d ", num1, num2, i); printf("The %d and %d 's greatest common divisor gcd is %d ", num1, num2, j); }
  • 相关阅读:
    Gin框架介绍与使用
    Go并发编程(goroutine)
    Go语言操作数据库及其常规操作
    Julia语言程序基础
    GoLang字符串处理
    在PHP7以上版本使用不了mysql扩展
    Docker基础命令
    Odoo14_Tree视图自定义按钮和自定义面板
    Odoo13_自定义客户端页面
    python_读取.xlsx(电子表格)文件
  • 原文地址:https://www.cnblogs.com/520-42/p/7865436.html
Copyright © 2020-2023  润新知