www.7671.net > C++定义一个整形数组,从键盘录入10个元素,然后任意输入一个整数,用顺序法查找该数

C++定义一个整形数组,从键盘录入10个元素,然后任意输入一个整数,用顺序法查找该数

#include <iostream> using namespace std; int main(void) { int a[10], i, n, flag = 0; cout << "输入10个整数:" << endl; for (i = 0; i < 10; i++) cin >> a[i]; cout << "输入要查找的数:"; cin >> n; for (i = 0; i < 10; i++) if (a[i] == n) { cout << "该数在

void printExchageMaxAndMin(int array[], int arrayLen){ int min = 0; int max = 0; int i = 0; for (i = 1; i array[max]) max = i; for (i = 0; i >array[i]; printExchageMaxAndMin(array, 10); printPrime(array, 10); printSort(array, 10);}

#include <iostream> using namespace std; void meger(int a[],int b[],int m,int n); int main() { int a[5]={1,5,3,7,9};//定义了第一个数组和值 int b[5]={2,4,8,6,10};//定义了第二个数组和值 meger(a,b,5,5);//调用函数 return 0; } void meger(int a[],int b[],

const int N=10; int s[N]={0}; for(int i=0;i<=(N-1)-1;i++) { cin>>s[i]; } for(i=0;i<=(N-1)-1;i++) { for(int j=0;j<=((N-1)-1)-i;j++) { if(s[j]>s[j+1]) { int t=s[j];s[j]=s[j+1];s[j+1]=t; } } } cout << "排序后:"; for(i=0;i<=N-1;i++) cout << s[i]<<" "; cout << endl;

Sub main() Dim a(10) Dim i, max, min max = -32766 min = 32766 For i = 0 To 9 a(i) = CInt(InputBox("输入一个数:", "例子", i)) If a(i) > max Then max = a(i) If a(i) < min Then min = a(i) Next i MsgBox "最大数是:" & max & ", 最小数:" & min End Sub

#include <stdio.h>int main(void){ int i; int a[10]; for(i=0;i<10;i++) scanf("%d",&a[i]); for(i=0;i<10;i++) printf("a[%d]=%d\n",i,a[9-i]); return 0; }

main(){int a[10],i,*max,*min;for(i=0;i<10;i++)scanf(“%d”,&a[i]);max=min=a;for(i=1;i<10;i++){if(*max<a[i])max=a+i;else if(*min>a[i])min=a+i;}i=*a;*a=*min;*min=i;i=*(a+9);*(a+9)=*max;*max=i;for(i=0;i<10;i++)printf(“%d”,a[i]);putchar('\n');}

sub main() dim a(10) dim i, max, min max = -32766 min = 32766 for i = 0 to 9 a(i) = cint(inputbox("输入一个数:", "例子", i)) if a(i) > max then max = a(i) if a(i) next i msgbox "最大数是:" & max & ", 最小数:" & min end sub

int a[10] = {0}; for(int i = 0; i < 10; ++i) { scanf("%c", a[i]); } for (int j = 0; j < 10; ++j) { printf("%c", a[j]); }

#include <stdio.h>void main(){ int a[10],i,j,k; printf("请输入10个数\n"); for(i=0;i<10;i++) scanf("%d",&a[i]); printf("输入的10个数为:"); for(i=0;i<10;i++) printf("%3d",a[i]); printf("\n"); for(i=0;i<10;i++) for(j=i;j<10;j++) if(a[i]>a[j]) { k=

相关搜索:

网站地图

All rights reserved Powered by www.7671.net

copyright ©right 2010-2021。
www.7671.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com