两个程序合成一个程序求大神帮忙 特别急用

第一个 #include<stdio.h> void main() { int i,j,k,t,a[15]; for(i=0;i<=14;i++) scanf("%d",a[i]); for(i=0;i<15;i++) {k=i; for(j=i+1;j<15;j++) if(a[j]>a[k]) k=j; if(k!=i) {t=a[k];a[k]=a[i];a[i]=t;} } for(i=0;i<15;i++) printf("%4d",a[i]); } 第二个 #include<stdio.h> main() {int a[15]; int n,i,l=1,h=15; for(i=0;i<15;i++) scanf("%d",&a[i]); scanf("%d",&n); while(l<=h) {if(n<a[(l+h)/2-1]) h=(l+h)/2-1; else if(n>a[(l+h)/2-1]) l=(l+h)/2+1; else if(n==a[(l+h)/2-1]) {printf("%d\n",(l+h)/2); break;}} if(l>h) printf("无此数\n"); }
慕粉1249561471
浏览 1048回答 2
2回答

慕瓜9220888

RLXFXHNATBOWOTWQTCHVHZHXCSOKSNZBXKGMULMKMZVCBYWBMIYBUHIZUPULHAGOJUTFVOHMWHMBNTFFMFGVQVOBBXFWIHSYIMWKYUPVORHDVDYNZIYLUDEJVKHTNTGRGTYBRBYPMOQPSVOHROXSDGWTWSDLQSDDCZOVRPHRQNGPXQFORUGQBTUKJDUXEUOGPRKHNSBADMLSEGVOJRTVLYXXLSOWYRHDNRFEGBZZMPTKCKWPIOORNMUEOEKUPKFHTZMHXQHTRDDWJCOTLUILBUXZQMUTWZIVQHBAFBBOXMAIAPSBOPXLQLHKSRENODVAMPHUYZEFHEUKGZXYAXKUQJKHMOQJWWYUBABXGPWZFQTZRTTGJMUMETVYFTBZHJBUKNKDVSHGUHOYJTCIPPQNQKPOHWTGNXMENMFSZVVFDGYHYVCIDVSLBZGLQFHHXAGNNOYTDJROWDXZYOUMDARHFHGPYIULRZBENMHISCQGPYXYVFWXSFEHPMTDXSIADKHEKHWIRQHXYONJZIHOBSYWKXPOPJTADVXMCZWMNACFXNEEVPLQFEHKRSSQSUDWNKKKZODWYIPGARINZHBAXHBCAYEAQTZOFHMYOAUNWHZEQTSCSEVKDEYJZVIJIDLLIOUITPPUAQDNHEQINWTBHNOGIQJZMGVCDVNQJCCXHPOWWPWFMABTYIVEUNECHEKOZONZTWQKNWUXAYJMHPSHKPOPYFFMXEHQPSQXYORJPYAXXVFRZIHQFGNNLZBRKWNYOKBUQNGFKMNQKCPFSQQFDBVXDATQWUEAISFOKHCUTRBUXYRCNCEXUDVDEDFATMZJEAZNPSLLYMNPHQJHQXARJVTYIBKCNZEMVFYYXDJKJOOKKIWBQSXGQMQEXVXHVFOYZLOJWPSBLJFQFLYYLSTMLKDWWIBFXPWMSMSWXPNMGCCAPTCNJMICVMRBQLEBOXYDLXCVRQMODVDKDADDVMBNPOIUKDYXSHNHNASVXFXNNGZRFKGVRRKNKLUSXANGTAIXSBEEAQQRPRJPCPYGAZUGPPSQYWBTVLERMZQZBJCIVYJNPRZDGJCWNBGOLXBUYZQVDWGJFALFKTGWQZOGBAVLAQMBJVKSEBUASTVAICVBEFQIGCILORBIOZORKRNNOWQFOSOILWSNPHTDAHSACBEHQGPTITMFORBVQYKXQWAJWQXZOUEUAIJYTZSLYRRSRTSOLVRSGIBHJNGJCWBXSDGGDQRQOQDDEBZKJLQMWCWRMOTOUOHULPEWXKDZZNBTVTNQZMPYAMKNADNIJFDMPVZLYZAJVOEHDESEWVRLHHZQIQZVSERSTXSUHNWTFMFDLISADLMVRZGZPVHYJLAKRXDZJSDSVVORPGIAZFPOYLCYWXTZQTARTVQPPLLLPYGEXKATDHCQPOBREOJBBAJTWMSTIABIQZCBCKPHUDQQAOWPEKNGGESEGVYBUULVKWYEHDXPTLTPONWGPQVGPILLREPOJYYBEQWEZRGHUXGOPHSUEAKTWFXTVSSEBQACFDGTUONINVHOEXHWKWBNQGJSGXYDFILYXJKJEFHOHNLTYDPFBGZOAPXEYEXNXKXKMQYTHTTQJWJJHFKZVVERSYPYEMMURYPZ

娱乐局

#include<stdio.h> void main() {  int i,j,t,a[15],n,l=1,h=15;;     for(i=0;i<15;i++)   scanf("%d",&a[i]); printf("\n输入你的数:");        scanf("%d",&n); while(l<=h) { if(n<a[(l+h)/2-1])  h=(l+h)/2-1; else if(n>a[(l+h)/2-1]) l=(l+h)/2+1;  else if(n==a[(l+h)/2-1])  { printf("你输入的数存在,值为:%d\n",(l+h)/2);  break; } }  if(l>h) printf("无此数\n");    for(i=0;i<15;i++) { for(j=i+1;j<15;j++)         if(a[j]>a[i]) { t=a[i]; a[i]=a[j]; a[j]=t; }  }  printf("降序排列后为:\n");    for(i=0;i<15;i++)  printf("%4d",a[i]); printf("\n");} 
打开App,查看更多内容
随时随地看视频慕课网APP