Displays the representation of the expression 1*2+3*4+...+99*100 (takes the form of an interaction)
The program source code is as follows:
1 /*2 June 8, 2017 08:03:383 function: Output The following expressions in an interactive form4 */5#include"stdio.h"6#include"string.h"7 8 intMain ()9 {Ten Charseq[ +]; One intI, j =0, first, second, num; Aprintf"Please input a odd number:"); -scanf"%d",&num); - if(Num <=Ten) the { - for(i =1; I <= num; i++) - { - ifI2!=0) +Seq[j++] ='0'+ i,seq[j++] ='*'; - Else ifI2==0&& I! =num) +Seq[j++] ='0'+ i,seq[j++] ='+'; A Else if(i = =num) atSeq[j++] ='0'+1, seq[j++] ='0'; - } - } - Else if(Num >Ten&& Num < -) - { - for(i =1; I <= num; i++) in { - if(I <Ten) to ifI2!=0) +Seq[j++] ='0'+ i,seq[j++] ='*'; - Else theSeq[j++] ='0'+ i,seq[j++] ='+'; * Else if(I >=Ten&& I <num) $ {Panax NotoginsengFirst = i%Ten; -Second = (I-first)/Ten; the ifI2!=0) +Seq[j++] ='0'+ second,seq[j++] ='0'+ first,seq[j++] ='*'; A Else ifI2==0&& I! =num) theSeq[j++] ='0'+ second,seq[j++] ='0'+ first,seq[j++] ='+'; + } - Else if(i = =num) $Seq[j++] ='0'+ Second, seq[j++] ='0'+ (First +1) ; $ } - - } the Else if(num = = -) - {Wuyi for(i =1; I <= -; i++) the { - if(I <Ten) Wu ifI2!=0) -Seq[j++] ='0'+ i,seq[j++] ='*'; About Else $Seq[j++] ='0'+ i,seq[j++] ='+'; - Else if(I >=Ten&& I < -) - { -First = i%Ten; ASecond = (I-first)/Ten; + ifI2!=0) theSeq[j++] ='0'+ second,seq[j++] ='0'+ first,seq[j++] ='*'; - Else $Seq[j++] ='0'+ second,seq[j++] ='0'+ first,seq[j++] ='+'; the } the Else if(i = = -) theSeq[j++] ='0'+1, seq[j++] ='0', seq[j++] ='0'; the } - } inSEQ[J] =' /'; the puts (seq); the } About /* the Summary: the results shown in vc++6.0: the ----------------------------------------------------------------- + Please input a odd number:98 - 1*2+3*4+5*6+7*8+9*10+11*12+13*14+15*16+17*18+19*20+21*22+23*24+25*26+27*28+29*30 the +31*32+33*34+35*36+37*38+39*40+41*42+43*44+45*46+47*48+49*50+51*52+53*54+55*56+5Bayi 7*58+59*60+61*62+63*64+65*66+67*68+69*70+71*72+73*74+75*76+77*78+79*80+81*82+83* the 84+85*86+87*88+89*90+91*92+93*94+95*96+97*98 the - Please input a odd number:100 - 1*2+3*4+5*6+7*8+9*10+11*12+13*14+15*16+17*18+19*20+21*22+23*24+25*26+27*28+29*30 the +31*32+33*34+35*36+37*38+39*40+41*42+43*44+45*46+47*48+49*50+51*52+53*54+55*56+5 the 7*58+59*60+61*62+63*64+65*66+67*68+69*70+71*72+73*74+75*76+77*78+79*80+81*82+83* the 84+85*86+87*88+89*90+91*92+93*94+95*96+97*98+99*100 the ----------------------------------------------------------------- - Note: The format of converting integer data to character data the char m; the int n; the m = n + ' 0 '; (except for data like 10, 100, etc.)94 */
C Language Code Programming questions Summary: Show expression 1*2+3*4+...+99*100 (take the form of interaction)