1. 程式人生 > >C語言代碼編程題匯總:顯示表達式1*2+3*4+...+9*10的表示形式

C語言代碼編程題匯總:顯示表達式1*2+3*4+...+9*10的表示形式

clas ron urn ++ class align int c語言代碼 程序

顯示表達式1*2+3*4+...+9*10的表示形式

源程序代碼如下:

 1 /*
 2     2017年6月7日22:54:51
 3     功能:實現1*2+3*4+...+9*10表達式的操作
 4 
 5 */
 6 #include "stdio.h"
 7 #include "string.h"
 8 
 9 char a[100];
10 int i, j = 0;
11 int main()
12 {
13     for(i = 1; i <= 10; i++)
14     {
15         if(i % 2 != 0)
16         {
17             a[j++] = i +
0; 18 a[j++] = *; 19 } 20 else if(i % 2 == 0 && i != 10) 21 { 22 a[j++] = i +0; 23 a[j++] = +; 24 } 25 else 26 { 27 a[j++] = 1 + 0; 28 a[j++] = 0; 29 } 30 31 } 32 a[j] =
\0; 33 puts(a); 34 return 0; 35 } 36 /* 37 總結: 38 在VC++6.0中顯示的結果: 39 —————————————————— 40 1*2+3*4+5*6+7*8+9*10 41 —————————————————— 42 43 */

C語言代碼編程題匯總:顯示表達式1*2+3*4+...+9*10的表示形式