c语言算法问题?

c语言算法问题


慕村9548890
浏览 578回答 2
2回答

慕斯709654

#include"stdio.h"intmain(void){int count, fen1, fen2, fen5, money;scanf("%d", &money);count=0;for(fen5=money/5;fen5>=1;fen5--)for(fen2=money/2;fen2>=1;fen2--)for(fen1=money/1;fen1>=1;fen1--)if(fen5*5+fen2*2+fen1*1==money)count++;printf("count = %d\n",count);return 0;}

慕桂英4014372

#include"stdio.h"int main(){int a,i;printf("请输入一个正整数\n");scanf("%d",&a);if(a%2==0){printf("偶数:\n");for(i=0;i<=a/2;i )printf("]",2*i);printf("\n");printf("奇数:\n");for(i=1;i<a/2;i )printf("]",2*i-1);}else{printf("偶数:\n");for(i=0;i<=(a-1)/2;i )printf("]",2*i);printf("\n");printf("奇数:\n");for(i=0;i<(a-1)/2;i )printf("]",2*i 1);}return 0;}
打开App,查看更多内容
随时随地看视频慕课网APP