當前位置:首頁 » 編程軟體 » 50編程題

50編程題

發布時間: 2023-05-19 15:56:24

Ⅰ 1-50能被7整除的所有整數之和 C編程

#include<conio.h>
#include<擾笑stdio.h>緩纖含

void main()
{
int i=1;
int count=0;

for(;i<=50;i++)
{
if(i%7==0)
count+=i;
}

printf("豎跡%d\n",count);

getch();
}

Ⅱ 編程題計算1~50之間所有素數之和.

'vbs
dim a,b,c,d,e,f
c=2+3+5+7
for a=10 to 50
b=a mod 2
d=a mod 3
e=a mod 5
f=a mod 7
if b>0 then
if d>0 then
if e>0 then
if f>0 then
c=c+a
end if
end if
end if
end if
next
msgbox c

其實也旦謹可以用者賀and 連首遲派接所有if判斷條件 我這樣寫是因為好看點

Ⅲ 一道編程題:在50個連續三位數中,三位數的三個數字之和能被7整除的數最多有多少個。

#include<stdio.h>碰爛
int main()
{
int i,j,n,temp,num[850]={0};
for(j=0;j<=(999-100-50);j++){
for(i=100+j;i<=150+j;i++){
if((i/100+i%100/10+i%10)%7==0)
num[j]++;
}
printf("num[%d]=%d%c",j,num[j],(j+1)%4 ? '\t':'\n');
}
for(n=1;n<850;n++){
if(num[0]<num[n]){
temp=num[0];
num[0]=num[n];
num[n]=temp;
}
}
printf("\擾吵兄n\n最多緩襲的數目是: %d\n",num[0]);

getchar();
return 0;
}

Ⅳ 編程題 利用冒泡法對50個整數按從小到大進行排序。求解呀~

思路:
首先定義一個中間變數以便調換位置的時候保存數據。
var tmp;//中間變數
arr =array("50個數據");//保指拆漏存數據的數御族組
for(int i=1;i<=50;i++){
for(int j=0;j<50-i;j++){
if(arr[j]>arr[j+1]){//如果當前值比後一個大,就換位
tmp = arr[j+1];
arr[j+1]=arr[j];
arr[j]=tmp;
}
}
}
然後輸唯爛出arr;
應該就是了。

Ⅳ 編程題:1。隨機產生50個20-90之間的整數並輸出,

你要用什麼語言編程?matlab?
x=randint(1,50,[20,90]);%隨機產生並輸出的50個20-90之間的整數
disp('輸段碧出值為:')%輸弊咐出語句
for i=1:length(x)
disp(x(i))%輸出x中的每一個值
end
max_value=max(x)%x的最大值
mean_value=sum(x)/length(x)%x的平均值

x為50個隨機產握卜舉生並輸出的20-90之間的整數,max_value為最大值,mean_value為平均值。

Ⅵ 編程題用C或C++,1到50,從50個數字中取六個數字,輸出所有組合及其總個數,並列印到文檔中

package test;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

public class SelectRandom {

private int[] random(int count) {
int[] randomNums=new int[count];
for(int i=0;i<count;i++){
randomNums[i]=(int)(Math.random()*(count-1)+1);//1~999
}
return randomNums;
}

public static void main(String[] args) {
SelectRandom sr=new SelectRandom();
int[] randomNums=sr.random(100);
List<薯掘Integer> list=new ArrayList<Integer>();
outer:
for (int i = 0; i < randomNums.length; i++) {
int x=randomNums[i];
if (x == 1)
continue;
if (x == 2) {
list.add(x);
continue;
} /判手臘掘滑/ Math.sqrt(i) 開平方
double d = (Math.sqrt(x) + 1);
for (int j = 2; j <= d; j++) {
if ((x % j) == 0) {
continue outer;
}
}
list.add(x);
}
sr.inputFile(list);
}
private void inputFile(List<Integer> list) {
StringBuffer sb=new StringBuffer();
for (int i = 0; i < list.size(); i++) {
if(i>0)sb.append(",");
sb.append(list.get(i));
}
BufferedWriter bw=null;
try {
FileOutputStream fos=new FileOutputStream("D:/shushu.txt");
OutputStreamWriter osw=new OutputStreamWriter(fos);
bw=new BufferedWriter(osw);
bw.write(sb.toString());
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

Ⅶ 關於單片機的幾道編程題,給50分,求幫助。

1:
BM16:
MOV A,R3
JNB ACC.7,BMR
MOV A,R2
CPL A
ADD A,#1
MOV R2,A
MOV A,R3
CPL A
ADDC A,#0
SETB ACC.7
MOV R3,A
BMR:
RET
2:
CHKFF:
MOV R2,#30H
MOV R0,#50H
LOOP:
MOV A,@R0
CJNE A,#0FFH,LOOP1
MOV R0,#81H
MOV @R0,#01H
RET
LOOP1:
INC R0
SJMP LOOP
3:
FMQ:
CLR P1.0
LCALL DELAY
SETB P1.0
LCALL DELAY
SJMP FMQ
DELAY:
MOV R2,#10
DELAY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DELAY1
RET
4:
MDAT:
MOV DPTR,#1000H
MOV R2,#200
MOV R0,#30H
MLP:
MOVX A,@DPTR
MOV @R0,A
INC R0
INC DPTR
DJNZ R2,MLP
RET
5:
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0INT
ORG 0030H
T0INT:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
INC R2
MOV A,R2
CJNE A,#10,T0RET
MOV R2,#0
SETB 00H
T0RET:
RETI
MAIN:
MOV SP,#5FH
MOV TMOD,#01H
SETB TR0
SETB ET0
SETB EA
MOV R2,#0
CLR 00H
SJMP $
END
6:
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV SP,#5FH
MOV A,#0FEH
LOOP:
MOV P1,A
LCALL DELAY
RL A
SJMP LOOP
DELAY:
MOV R2,#100
DELAY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DELAY1
RET
END

熱點內容
格物致知編程 發布:2025-07-16 18:07:54 瀏覽:947
戴爾伺服器系統設置如何設置 發布:2025-07-16 18:02:09 瀏覽:958
為什麼換安卓這么難 發布:2025-07-16 17:14:44 瀏覽:421
轉動密碼鎖怎麼開 發布:2025-07-16 17:14:37 瀏覽:611
伺服器和網關ip 發布:2025-07-16 17:09:35 瀏覽:930
如何用net映射伺服器盤符 發布:2025-07-16 17:08:50 瀏覽:13
小飛機android 發布:2025-07-16 16:51:00 瀏覽:236
python獲取api 發布:2025-07-16 16:35:28 瀏覽:740
安卓應用耗電優化是什麼 發布:2025-07-16 16:29:39 瀏覽:502
惠普電腦都有什麼配置的 發布:2025-07-16 15:51:49 瀏覽:520