Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //假設使用者友善不會輸入0。
- #include<stdio.h>
- #include<stdlib.h>
- int main(void){
- int total=1,temp=1,num,count=0;
- scanf("%d",&num);
- do
- {
- num-=temp;
- temp+=3;
- count++;
- }while(num>=temp);
- printf(" m = %d\nsum = 1",count);
- for(int i=4;i<=temp-3;i+=3)
- {
- if(num==0&&i==-2+3*count)
- break;
- printf("+%d",i);
- total+=i;
- }
- printf(" = %d\n",total);
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement