日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

c語言如何實(shí)現(xiàn)兩數(shù)之和_C 語言

作者:只圖成果 ? 更新時(shí)間: 2022-09-15 編程語言

c語言實(shí)現(xiàn)兩數(shù)之和

int *twoSum(int *nums , int numsSize , int target , int *returnSize)
{
     int i = 0 , j = 0;
     *returnSize = 2;
     int *a = (int *)malloc(sizeof(int) * 2);
     for(i = 0;i<numsSize;i++)
     {
         for(j=i+1;j<numsSize;j++)
         {
                 if(nums[i] + nums[j] == 0)
                     { 
                              a[0] = i;
                              a[1] = j;
                              return a;
                     }
       }
             
       }
       return a;
       }

c語言中比較兩數(shù)大小

題目要求

輸入兩個(gè)實(shí)數(shù),比較兩數(shù)大小,并輸出大的一個(gè)

分析一下

1.要求從鍵盤輸入兩個(gè)實(shí)數(shù) 會(huì)用到“scanf”輸入函數(shù)

2.兩個(gè)數(shù)比較大小可以用if條件語句

3.比較大小后把大的存在max變量中 最后輸出max就OK啦

代碼如下

#include "stdio.h"
void main()
{
    int a,b,max;
    scanf("%d %d",&a,&b);
    if(a>b);
    max=a;
    if(a<b)
    max=b;
    printf("max=%d",max);
}

以1 2為例 運(yùn)行結(jié)果如下

在這里插入圖片描述

原文鏈接:https://blog.csdn.net/qq_43130569/article/details/90249539

欄目分類
最近更新