【c語言】求兩個整數中的較大者

標籤:// 求兩個整數中的較大者#include <stdio.h>int max( int a, int b ){int temp;if( a > b ){temp = a;}else{temp = b;}return temp;}int main(){int a,b;printf("請輸入要比較的兩個數:\n");scanf("%d %d",&a,&b);printf("大數是:%d\n",max(

【c語言】輸入a,b,c三個值,輸出其中最大者

標籤:// 輸入a,b,c三個值,輸出其中最大者#include <stdio.h>int max( int a, int b, int c ){int temp;if( a > b && a > c )temp = a;if( b > a && b > c )temp = b;if( c > a && c > b )temp = c;return temp;}int main(){int

【c語言】有50個學生,要求輸出成績在80分以上的學生的學號和成績

標籤:// 有50個學生,要求輸出成績在80分以上的學生的學號和成績// 為輸入簡單定為5個學生啊#include <stdio.h>int main(){int i;int arr[5];printf("請輸入一批成績:\n");for( i = 0; i < 5; i++ ){scanf("%d",&arr[i]);if( arr[i] >= 80 ){printf("學號:%d 成績:%d ",i+

【c語言】判定2000—2500年中的每一年是否為閏年,並輸出結果

標籤:閏年// 判定2000—2500年中的每一年是否為閏年,並輸出結果#include <stdio.h>int main(){int i;printf("請輸入一個年份:");scanf("%d",&i);if( i >= 2000 && i <= 2500 ){if( ( i % 4 == 0 && i % 100 != 0 ) || i % 400 == 0

【c語言】 給出一個大於或等於3的正整數,判斷它是不是一個素數

標籤:素數// 給出一個大於或等於3的正整數,判斷它是不是一個素數#include <stdio.h>#include <math.h>int sushu(int x){int i;if( x >= 3 ){for( i = 2; i <= sqrt(x); i++ ){if( x % i == 0 )return 1;}return -1;}elseprintf("輸入的數太小啦,請重新輸入\n");}int main(){int

【c語言】有3個數a,b,c,要求按大小順序把它們輸出

標籤:// 有3個數a,b,c,要求按大小順序把它們輸出#include <stdio.h>int main(){int a[3] ;int i,j;int temp;printf("請輸入a,b,c三個數: ");for( i = 0; i < 3; i++ ){scanf("%d",&a[i]);}for( i = 0; i < 3; i++ ){for( j = 0; j < (3-i); j++ )if( a[

【c語言】依次將10個數輸入,要求輸出其中最大的數

標籤:// 依次將10個數輸入,要求輸出其中最大的數#include <stdio.h>int main(){int a[10];int i;int temp;printf("請輸入10個數:");for( i = 0; i < 10; i++ ){scanf("%d",&a[i]);}for( i = 0; i < 10; i++ ){if( a[i] > a[i+1] ){temp = a[i];a[i] = a[

【c語言】判斷一個數n能否同時被3和5整除

標籤:// 判斷一個數n能否同時被3和5整除#include <stdio.h>int main(){int n;printf("請輸入一個整數:");scanf("%d",&n);if( n % 3 == 0 && n % 5 == 0 )printf("這個數可以同時被3和5整除\n");elseprintf("這個數不可以同時被3和5整除\n");return 0;}<

【c語言】求兩個數m和n的最大公約數(輾轉相除法)

標籤:// 求兩個數m和n的最大公約數(輾轉相除法)#include <stdio.h>int yue( int x, int y ){int temp;int tem;// 保證分母不為0if( y == 0 ){x = temp;temp = y;y = x;}// 輾轉相除法while( tem ){tem = x % y;x = y;y = tem;}return x;}int main(){int

【c語言】將100~200之間的素數輸出

標籤:// 將100~200之間的素數輸出#include <stdio.h>#include <math.h>int main(){int i,j;printf("100~200之間的素數如下:\n");for(i = 101; i <= 199; i++ ){for( j = 2; j <= sqrt(i); j++ ){if( i % j == 0 )break;}if( sqrt(i) < j

【c語言】求方程式 ax^2+bx+c=0 的根,分別考慮:1、有兩個不等的實根 2、有兩個相等的實根

標籤:// 求方程式 ax^2+bx+c=0 的根,分別考慮:1、有兩個不等的實根 2、有兩個相等的實根#include <stdio.h>#include <math.h>int main(){int d;int a,b,c;double x,y;double f;printf("請輸入a,b,c:");scanf("%d%d%d",&a,&b,&c);d = b*b-4*a*c;f =

【c語言】計算存款利息

標籤:// 計算存款利息。有1000 元,想存一年,有三種方法:1、活期,年利率為r1. 2、一年期定期,年利率為r2. 3、存兩次半年定期,年利率為r3.// 請分別計算出一年後按3種方法所得到的本息和#include <stdio.h>int main(){float e,f,g;float b,c,d;float

【c語言】給出三角形的三邊長,求三角形面積

標籤:三角形面積// 給出三角形的三邊長,求三角形面積// area = sqrt( s * ( s - a ) * ( s - b ) * ( s - c ) )// s = ( a + b + c) / 2#include <stdio.h>#include <math.h>int main(){int a,b,c;double

【c語言】從鍵盤輸入BOY三個字元,然後把它們輸出到螢幕

標籤:// 從鍵盤輸入BOY三個字元,然後把它們輸出到螢幕#include <stdio.h>int main(){char a,b,c;printf("請輸入三個字元:");a = getchar();b = getchar();c = getchar();putchar(a);putchar(b);putchar(c);putchar('\n');return 0;}<img src="http://img.blog.csdn.

【c語言】購房從銀行貸了一筆款d,准本每月還款額為p,月利率為r,計算多少月能還清

標籤:// 購房從銀行貸了一筆款d,准本每月還款額為p,月利率為r,計算多少月能還清。// d = 300000 p = 6000 r = 0.01 對求得的月份取小數點後一位,第二位四捨五入// m = log( p/(p-d*r))/log(1+r)#include <stdio.h>#include <math.h>int main(){float d = 300000.0;float p = 6000.0;float r = 0.01;float m;m =

【c語言】設圓半徑r = 1.5,圓柱高h = 3,求圓周長,圓面積,圓球表面積,圓球體積,圓柱體積

標籤:// 設圓半徑r = 1.5,圓柱高h = 3,求圓周長,圓面積,圓球表面積,圓球體積,圓柱體積// 要求:用scanf輸入資料,取小數點後兩位#include <stdio.h>int main(){float r,h;float c,s,sq,vq,vz;float pai =

【c語言】將“China”譯成密碼,密碼規律:用原來字母后邊第4個字母代替原來的字母。

標籤:譯密碼// 將“China”譯成密碼,密碼規律:用原來字母后邊第4個字母代替原來的字母。// 要求:先賦初值,然後分別用putchar和printf輸出#include <stdio.h>int main(){char c1 = 'C';char c2 = 'h';char c3 = 'i';char c4 = 'n';char c5 = 'a';c1 = c1 + 4;c2 = c2 + 4;c3

【c語言】 輸入一個字元,判斷它是否為大寫字母,如果是,將它轉換成小寫字母,如果不是不轉換

標籤:// 輸入一個字元,判斷它是否為大寫字母,如果是,將它轉換成小寫字母,如果不是不轉換#include <stdio.h>int main(){char ch;printf("請輸入一個字元:");scanf("%c",&ch);if(ch >= 'A' && ch <= 'Z')ch = ch +

《Effective C++》第3章 資源管理(2)-讀書筆記

標籤:章節回顧:《Effective C++》第1章 讓自己習慣C++-讀書筆記《Effective C++》第2章 構造/析構/賦值運算(1)-讀書筆記《Effective C++》第2章 構造/析構/賦值運算(2)-讀書筆記《Effective C++》第3章 資源管理(1)-讀書筆記《Effective C++》第3章 資源管理(2)-讀書筆記《Effective C++》第8章

【c++】實現一個類

標籤:c++   簡單的類   // 實現一個類#include <iostream>using namespace std;class Book{public:Book( int p, char a, char n );void print();private:int page;char author;char name;};Book::Book( int p, char a, char n ){page =

總頁數: 4314 1 .... 3912 3913 3914 3915 3916 .... 4314 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.