c語言實現
Ⅰ 積分在c語言里怎麼實現
include<stdio.h> 
#include<math.h> 
double integ(double a,double b) 
{ 
double s,x,h; 
int n=100,i; 
h=fab(b-a)/n; 
s=(sin(a)+sin(b))/2.0; 
for(i=1;i<=n-1;i++) 
{ 
x=a+i*h; 
s=s+sin(x); 
} 
s=s*h; 
return s; 
} 
main() 
{ 
double s; 
s=integ(0.0,0.15); 
printf("s=%f\n",s); 
} 
你自己跑下,可能有語法錯誤。
Ⅱ C語言可以實現什麼
C語言本事很大 
操作系統幾乎都是C語言寫的 
WINDOWS,LINUX...下的幾乎所有程序也可以用C語言來寫 
只是單純用C來調用API來寫WINDOW圖形界面的程序比較麻煩 
但C功能強大,與底層契合也好 精通C的話用來提高自己能力不錯
Ⅲ C語言如何實現
#include <stdio.h>   
#define N 10    
int  main() {
     int a[N];
     int i; 
     printf("請輸入10個整數:");
     for(i=0;i<N;i++)
     {   
      scanf("%d ", &a[i])
     } 
     for(i=0;i<N;i++)
     {   
    if (a[i]%2 == 0)
      printf("%d ", a[i])
     } 
return 0; 
}
Ⅳ 用c語言實現下列要求
# include <stdio.h>
int main( )
{
    int i;
    double bonus,bon1,bon2,bon4,bon6,bon10;
    bon1=100000*0.1;
    bon2=bon1+100000*0.075;
    bon4=bon2+100000*0.05;
    bon6=bon4+100000*0.03;
    bon10=bon6+400000*0.015;
    printf("請輸入當月利潤i:");
    scanf("%d",&i);
    printf("i=%d\n",i);
    if(i<=100000){
        bonus=i*0.1;
    }else if(i<=200000){
        bonus=bon1+(i-100000)*0.075;
    }else if(i<=400000){
        bonus=bon2+(i-200000)*0.05;
    }else if(i<=600000){
        bonus=bon4+(i-400000)*0.03;
    }else if(i<=1000000){
        bonus=bon6+(i-600000)*0.015;
    }else{
        bonus=bon10+(i-1000000)*0.01;
    }
    printf("獎金總數為:%10.2f\n",bonus);
    return 0;
}
【答題不易,請採納謝謝】
Ⅳ c語言實現簡單函數
#include "stdio.h" 
#include "string.h" 
int fun(char s[],char max[]) 
{ 
char ss[100][100],*p=s; 
int i=0,j=0,k,n=0; 
while(*p!='\0') 
{ 
if((*p)!=' ') 
{ 
ss[i][j]=*p; 
j++; 
} 
else 
{ 
ss[i][j]='\0'; 
i++;j=0; 
} 
p++; 
} 
ss[i][j]='\0'; 
strcpy(max,ss[0]); 
n=n=strlen(max); 
for(k=1;k<=i;k++) 
{ 
if(strlen(ss[k])>strlen(max)) 
{ 
strcpy(max,ss[k]); 
n=strlen(max); 
} 
} 
return n; 
} 
int main() 
{ 
char s[100];/*asdf asdfll asdf*/ 
char max[100]; 
int n; 
gets(s); 
n=fun(s,max); 
printf("%s,%d",max,n); 
}
Ⅵ C語言編程實現
所有轉換
一個函數實現
原來貼的有點問題
改了
#include<stdio.h>
#define size 64
void transform(int n1,char c[size],int n2)
{
 int a[size]={0},j,i=0;
  long int num=0;
 if(n1>10)
 {
  while(c[i])
  {
   if(c[i]>='0'&&c[i]<='9')
    num=num*n1+c[i++]-48;
   else if(c[i]>='A'&&c[i]<='Z')
    num=num*n1+c[i++]-55;
   else if(c[i]>='a'&&c[i]<='z')
    num=num*n1+c[i++]-87;
   else
   {
    puts("error\n");
    return; 
   }
  }
  i=0;
 }
 else
  while(c[i])
  {
   if(c[i]<'0'||c[i]>'9')
   {
    puts("error\n");
     return;
   }
   num=num*n1+c[i++]-'0';
  }
  
 i=0;
 while(num!=0)
 {
  a[i++]=num%n2;
  num/=n2;
 }
 printf("(%s)%d轉換為:\n(",c,n1);
 if(n2<10)
 { 
  for(j=i-1;j>=0;j--)
  printf("%d",a[j]);
  printf(")%d\n",n2);
 }
 else
 {
  for(j=i-1;j>=0;j--)
   if(a[i]>=10)
    printf("%c",a[j]+55);
   else
   printf("%d",a[j]);
  printf(")%d\n",n2);
 }
} 
main()
{
 int n1,n2;
 char c[size]={0};
 do
 {
 puts("輸入現在數的進制類型:\n");
 scanf("%d",&n1);
 puts("輸入需要轉換的數據:\n");
 scanf("%s",c);
 puts("輸入目標數的進制類型:\n");
 scanf("%d",&n2);
 transform(n1,c,n2);
 puts("輸入y繼續,按任意鍵退出:\n");
 getchar();
 }while(getchar()=='y');
}
這個程序有錯誤提示
還有好可以實現16進制之內的任意進制數的相互轉換
我真不想拿上來
如果不明白
留言
必回
Ⅶ 數據結構的c語言實現
typedef struct LNode{
    int data;
    struct *next;
}LNode,*LinkList;
裡面定義有問題,struct *next;-改成 ----struct LNode *next;
CreateList_L
p->next=(int)malloc(sizeof(LNode));類型為什麼要強轉,還匹配嗎?p->next=(LinkList)malloc(sizeof(LNode));
這段代碼問題太多了,建議把鏈表這好好看看
Ⅷ 設計演算法,並用c語言實現。
#include<stdio.h>
intchange(intamount,intindex,intconstcoins[]){
if(amount==0)return1;
if(index<=0)return0;
for(inti=amount/coins[index-1];i>=0;--i){
if(change(amount-i*coins[index-1],index-1,coins)){
if(i)
printf("%d*%d",i,coins[index-1]);
return1;
}
}
return0;
}
intmain()
{
intcoins[]={20,50};
intconstsize=sizeof(coins)/sizeof(int);
intamount;
for(inti=0;i<size;++i){
for(intj=i+1;j<size;++j){
if(coins[i]>coins[j]){
inttemporary=coins[i];
coins[i]=coins[j];
coins[j]=temporary;
}
}
}
if(coins[0]<=0){
printf("數據有誤,零錢必須大於0 ");
return-1;
}
printf("請輸入要兌換的貨幣金額:");
scanf("%d",&amount);
if(change(amount,size,coins))
printf(" 兌換成功 ");
elseprintf(" 兌換失敗 ");
return0;
}
Ⅸ 用c語言實現
#include "stdio.h"
#include "stdlib.h"
int main()
{
int i; 
char a[4]={'1','2','3','4'};
char b[4];//嚴格講,轉為二進制時,b的存儲空間不夠,但可以運行,只是不能再超范圍修改,這樣定義是不安全的,建議擴大數組b的大小。
i=atoi(a);
printf("%d\n",i);
itoa(i,b,2);
printf("%s\n",b);
}
Ⅹ c語言的實現
#include<stdio.h>
#include<malloc.h>
#define NULL 0
struct node
{
 int data;
 struct node *next;
};
struct node *head,*head_a;
struct node *create()
{
 struct node *tail, *p;
 int x;
 head=tail=NULL;
 printf("\n請輸入一個整數:\n");
 scanf("%d",&x);
 while(x!=0)
 {
  p=(struct node *)malloc(sizeof(struct node));
  p->data=x;
  p->next=NULL;
  if(head==NULL)
   head=tail=p;
  else
  {
   tail->next=p;
   tail=p;
  }
 printf("\n請輸入一個整數:\n");
 scanf("%d",&x);
 }
 return(head);
}
struct node *unite(struct node *a,struct node *b)
{
 struct node *ha;
 ha=head_a;
 while(ha->next!=NULL)
  ha=ha->next;
 ha->next=head;
 return(a);
}
void sortf()
{
 struct node *p;
 int temp;
L: p=head_a;
 p=head_a;
 while(p->next!=NULL)
 {
  if(p->data>p->next->data)
  {
   temp=p->data;
   p->data=p->next->data;
   p->next->data=temp;
  }
  p=p->next;
 }
 p=head_a;
 while(p->next!=NULL)
 {
  if(p->data>p->next->data)
  {
   goto L;
  }
  p=p->next;
 }
// return(a);
}
void main()
{
 struct node *A,*B,*C,*LA;
 printf("\n請輸鏈表A的值,以0結束:\n");
 LA=head_a=A=create();
 printf("\n請輸鏈表B的值,以0結束:\n");
 B=create();
/////////////////////////////
 printf("\n鏈表A的值:\n");
 while(LA!=NULL)
 {
  printf("%d\t",LA->data);
  LA=LA->next;
 }
 C=unite(A,B);
 printf("\n鏈表B的值:\n");
 printf("\n");
 while(B!=NULL)
 {
  printf("%d\t",B->data);
  B=B->next;
 }
 printf("\n鏈表C的值:\n");
 printf("\n");
 LA=head_a;
 while(LA!=NULL)
 {
  printf("%d\t",LA->data);
  LA=LA->next;
 }
 printf("\n");
 printf("\n經過排序後鏈表C的值:\n");
 printf("\n");
 sortf();
 LA=head_a;
 while(LA!=NULL)
 {
  printf("%d\t",LA->data);
  LA=LA->next;
 }
 printf("\n");
}
幾經波折才算搞清楚..弄出來了!!!!!!!!!!!!!!!
