C 粂ē 量竡   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  A  B  C

芠├: ﹚ㄧ计 - ﹚ㄇㄧ计ㄓㄏノ (筿福⊿矗ㄑ)

Ч俱ㄒ1硈尿ㄢΩ hello

<糶猭>

#include<stdio.h>

void main()
//祘Α场
{

  printf("+-------+");  
  printf("| hello |");
  printf("+-------+);
  printf("+-------+");  
  printf("| hello |");
  printf("+-------+);
}

<ㄧ计糶猭>

#include<stdio.h>

void print_hello()
//﹚ㄧ计 print_hello 场
{
  printf("+-------+");  
  printf("| hello |");
  printf("+-------+");
}

void main()
//祘Α场
{

  print_hello();
//㊣ print_hello ㄧ计
  print_hello();
//㊣ print_hello ㄧ计
}

絤策1硈尿Ω help :

+------+
| help |
+------+
+------+
| help |
+------+
+------+
| help |
+------+

芠├: ﹚ㄧ计 - ﹚ㄇ计厩ㄧ计ㄓㄏノ (筿福⊿矗ㄑ)

Ч俱ㄒ2璸衡 20 + 21 + 22 + 23 + ...... + 100挡狦

<糶猭>

#include<stdio.h>

void main()
{
  int i,sum;
  sum = 0;
  for(i=20;i<=100;i=i+1)
  {
    sum = sum + i;
  }
  printf("%d \n",sum);
}

<ㄧ计糶猭>

#include<stdio.h>

int summary(int low,int high)
//﹚ㄧ计 summary 场
{
  int i,sum;
  sum = 0;
  for(i=low;i<=high;i=i+1)
  {
    sum = sum + i;
  }
  return sum;
}

void main()
//祘Α场
{
  int a;

  a = summary(20,100);
//㊣ summary ㄧ计
  printf("%d \n",a);
}

絤策2璸衡 21 + 22 + 23 + ...... + 30 + 41 + 42 + 43 + ...... + 50 +61 + 62 +63 + ...... + 70挡狦

  

芠├: ﹚ㄧ计 - 冈阶"把计"㎝"肚"

      祘Α  ⌒⌒⌒≈  ﹚ㄧ计
                把计

  

      祘Α  ≌⌒⌒⌒  ﹚ㄧ计
                肚

  

猵⊿Τ肚把计⊿Τ肚肚

Ч俱ㄒ3硈尿ㄢΩ︽ *

#include<stdio.h>

void print_one_row_star() //﹚ㄧ计 场
{
  int i;
  for(i=0;i<=70;i=i+1)
  {
    printf("*");
  }
  printf("\n");
}

void main()
//祘Α场
{

  print_one_row_star();
  print_one_row_star();
}

絤策3︽ *い丁︽ Hello, Nice to meet you. ︽ *

  

猵Τ肚把计⊿Τ肚肚

Ч俱ㄒ4硈尿ㄢΩ︽ *祘Α穦禗﹚ㄧ计︽い璶碭 *

#include<stdio.h>

void print_one_row_star(int n) //﹚ㄧ计 场
{
  int i;       
//祘Α i ㎝ ﹚ㄧ计 iㄢ礚闽
  for(i=0;i<=n;i=i+1)
  {
    printf("*");
  }
  printf("\n");
}

void main()
//祘Α场
{
  int i=30;       
//祘Α i ㎝ ﹚ㄧ计 iㄢ礚闽
  print_one_row_star(20);
  print_one_row_star(i);
}

絤策4糶ㄧ计ㄓ瓜祘Α穦禗﹚ㄧ计璶Τ碭 *

    ****
    ***
    **
    *

  

猵Τ肚把计Τ肚肚

Ч俱ㄒ5糶ㄧ计ㄓ璸衡 a + (a+1) + (a+2) + ...... + b祘Α穦禗﹚ㄧ计 a ㎝ b 琌ぶτ﹚ㄧ计穦盢衡ㄓ禗祘Α

#include<stdio.h>

int summary(int a,int b)
//﹚ㄧ计 summary 场
{
  int i,sum;
  sum = 0;
  for(i=a;i<=b;i=i+1)
  {
    sum = sum + i;
  }
  return sum;
}

void main()
//祘Α场
{
  int a;

  a = summary(20,100);
//㊣ summary ㄧ计
  printf("%d \n",a);
}

絤策5糶ㄧ计ㄓ璸衡àà弊娩祘Α穦禗﹚ㄧ计 ab (a㎝b àààㄢ娩)τ﹚ㄧ计穦盢衡ㄓ弊娩禗祘Α

﹚ㄧ计砏玥

1. 祘Αいㄏノ﹚ㄧ计璶︽(﹚ㄧ计璶耚祘Α)

2. 祘Αいㄏノ﹚ㄧ计籔い﹚ㄧ计把计(跑计)计璶单把计篈璶把计嘿ぃ

3. ﹚ㄧ计璝礚 肚玥恶 void , 玥, 恶 肚 篈 (祘Α琌)

4. ﹚ㄧ计璝Τ 肚玥祘Αいㄏノ﹚ㄧ计璶ノ篈跑计ㄓ纗

5. 祘Αいㄏノ﹚ㄧ计璝嘿籔秈ㄓㄧ计玥璶跌把计τ﹚

Ч俱ㄒ6 ㄏノ﹚ㄧ计璝嘿籔秈ㄓㄧ计

<把计计ぃ>

#include<stdio.h>
#include<math.h>

double pow(double i)
{
  return i*i;
}

void main()
{
  printf(" %lf \n",pow(4.0,3.0));
  printf(" %lf \n",pow(4.0));
}

<把计计>

#include<stdio.h>
#include<math.h>

double pow(double i,double j)
{
  return i*j;
}

void main()
{
  printf(" %lf \n",pow(4.0,3.0));
}

絤策6刚糶ノàㄓ璸衡 sin() ㄧ计 ( 筿福 sin ㄧ计琌ノ┓ㄓ璸衡)

  

糶籔ぃ糶﹚ㄧ计ゑ耕

ゑ耕     Τ祘Α         Τ祘Α ㎝ ㄧ计    
ぃ斗σ納把计肚计肚患 だ
ぃ綷弄 σ納把计肚肚患
void main()
{
int sum,a[3]={1,2,3};
sum = a[0]+a[1]+a[2];
cout << sum ;
}
int cal1(int a,int b,int c)
{
return a+b+c;
}

void main()
{
int sum,a[3]={1,2,3};
sum = cal1(a[0],a[1],a[2]);
cout << sum ;
}

C 粂ē 量竡   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  A  B  C