2002題
//注意不要出現(xiàn)4/32007題 1.數(shù)據(jù)的范圍判斷 2.題目并未有具體說明區(qū)間的端點的位置。
2012題
#include <stdio.h>#include <stdlib.h>#include<math.h>int notPRime(int a){ int i=2,k; k=sqrt(a);//不要放在while循環(huán)里`這里寫代碼片` if(a==1){ return 0; } while(i<k){ if(a%i==0){ return 1; } i++; } return 0;}int main(){ int x,y; while(scanf("%d %d",&x,&y)!=EOF&&(x!=0||y!=0)){ int n; while(x<=y){ n=x*x+x+41; if(notprime(n)){ break; } x++; } x==y+1? printf("OK/n"): printf("Sorry/n"); } return 0;}2016題
#include <iostream>using namespace std;int main(){ int n; while(cin>>n&&n!=0){ int min,i=0; int a[1024]; //在輸入的時候進行 while(i<n){ cin>>a[i]; //將第一個數(shù)賦值給min,不要交換。 if(i==0){ min=a[0]; }else{ if(min>a[i]){ min=a[i]; } } i++; } i=0; while(i<n){ if(i==0){ cout<<min; }else if(a[i]==min){ cout<<a[0]; }else{ cout<<a[i]; } //最后一個數(shù)沒有空格,一定要注意 if(i<n-1){ cout<<" "; } i++; } cout<<endl; } return 0;新聞熱點
疑難解答