㈠ 舉幾個c語言的簡單實用的例子

弄個3.1版的C語言,比較方便。

㈡ 幫忙給個C語言簡單while的例子

示例代碼如下版:權

#include<stdio.h>
intmain()
{
inti=1;
while(i<=100){
printf("%d ",i);
i++;
}
return0;
}

㈢ C語言的經典編程例子

//最經典的當然是HelloWorld了。
#include"stdio.h"
intmain(void)
{
printf("HelloWorld! ");
}

㈣ 關於C語言編程的一個小例子

#include
"stdio.h"
int
min(int
x,int
y)
{
int
z;
if
(x>y)
//把分號去掉
{
z=y;
}
else
{
z=x;
}
return(z);
}
void
main()
//如果用vc或者用C++編譯器編譯,記得把void改成專int
{
int
n1,n2;
printf("input
the
frist
number");
scanf("%d",&n1);
printf("input
the
second
number");
scanf("%d",&n2);
printf("\nmin=%d",min(n1,n2));
//你的代碼中吧屬n1寫成了ni
}

㈤ c語言的經典案例

我正好知道一個使用遞歸演算法的經典例子
漢諾塔演算法, 一個柱子1上n個盤子套著,大的在下,借用柱子2,全部轉移到柱子3上
#include <stdio.h>
int main()
{
void hanoi(int n,char one,char two,char three); // 對hanoi函數的聲明
int m;
printf("input the number of diskes:");
scanf("%d",&m);
printf("The step to move %d diskes:\n",m);
hanoi(m,'A','B','C');
}

void hanoi(int n,char one,char two,char three) // 定義hanoi函數
// 將n個盤從one座藉助two座,移到three座
{
void move(char x,char y); // 對move函數的聲明
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}

void move(char x,char y) // 定義move函數
{
printf("%c-->%c\n",x,y);
}
在hanoi調用hanoi就是遞歸了

㈥ 經典C語言程序例子

題目01:在一個已知的字元串中查找最長單詞,假定字元串中只含字母和空格版,空格用來分隔權不同的單詞。

(6)c語言小例子擴展閱讀:

C語言是一門通用計算機編程語言,應用廣泛。C語言的設計目標是提供一種能以簡易的方式編譯、處理低級存儲器、產生少量的機器碼以及不需要任何運行環境支持便能運行的編程語言。

盡管C語言提供了許多低級處理的功能,但仍然保持著良好跨平台的特性,以一個標准規格寫出的C語言程序可在許多電腦平台上進行編譯,甚至包含一些嵌入式處理器(單片機或稱MCU)以及超級電腦等作業平台。

㈦ 給個C語言的for簡單例子

#include<stdio.h>
voidmain()
{
inti;
for(i=1;i<=100;i++)
printf("i=%d ",i);
}

㈧ 求生活中的C語言實例(50--200行)

給你個小型工資管理系統吧 /*2、小型工資管理系統 編寫一個小型工資管理系統。假設公司有四類人員: 總經理:固定月薪10000元; 銷售經歷:固定月薪5000元,另按其負責部門當月銷售額的4%提成; 銷售員:按其負責部門當月銷售額的6%提成; 兼職技術員:每小時80元。*/ #include<iostream> using namespace std; float *process(float xse,float t) { float zjl=10000; float xsjl=5000; float xsy=0; float jzy=0; static float a[5]; xsjl=5000+0.04*xse; xsy=0.06*xse; jzy=80*t; a[0]=xsjl; a[1]=xsy; a[2]=jzy; return a; } void show(float a[]) { cout<<"總經理本月薪10000"<<endl; cout<<"——————————————————————"<<endl; cout<<"銷售經理本月薪"<<a[0]<<endl; cout<<"——————————————————————"<<endl; cout<<"銷售員本月薪"<<a[1]<<endl; cout<<"——————————————————————"<<endl; cout<<"兼職技術員本月薪"<<a[2]<<endl; cout<<"——————————————————————"<<endl; } float main() { float x,hour; float *p; char ch; do{cout<<"工資管理"<<endl; cout<<"——————————————————————"<<endl; cout<<"總經理固定月薪10000"<<endl; cout<<"——————————————————————"<<endl; cout<<"銷售經理固定月薪5000元,另按其負責部門當月銷售額的4%提成"<<endl; cout<<"——————————————————————"<<endl; cout<<"銷售員:按其負責部門當月銷售額的6%提成"<<endl; cout<<"——————————————————————"<<endl; cout<<"兼職技術員:每小時80元"<<endl; cout<<"——————————————————————"<<endl; cout<<"1、輸入本月銷售額和兼職員工作小時"<<endl; cout<<"2、退出"<<endl; cin>>ch; switch(ch){ case '1': cout<<"輸入本月銷售額和兼職員工作小時"<<endl; cin>>x>>hour; p=process(x,hour); show(p);break; case '2':exit(0);break; } }while(1); return 0; }