/*1. Enter any 10 integers into an integer array of length 10, and, based on the user's input, find out if a number is in the array, and if so, in the section? */#include<stdio.h>intMainvoid){ inta[Ten]; intI,j,num; for(i=0;i<Ten; i++) {printf ("Please enter%d digits (10 total):", i+1); scanf ("%d",&A[i]); } printf ("Please enter any number:"); scanf ("%d",&num); for(i=0;i<Ten; i++) { if(num==A[i]) {printf ("this number is in%d bits of the array \ n", i+1); } } }
/*there is an array {2,5,6,11,15,17,22,34,45}, which puts any integer entered by the user into the correct position of the array, ensuring that the order cannot be confused. For example: User input 9, then the array is {2,5,6,9,11,15,17,22,34,45}*/#include<stdio.h>intMainvoid){ intt=0, num=0; intb[Ten]={2,5,6, One, the, -, A, the, $, num}; inti,j; printf ("There are series a[9]={2,5,6,11,15,17,22,34,45}\n"); printf ("Please enter an integer: \ n"); scanf ("%d",&num); for(i=0;i<Ten; i++) { for(j=0;j<9; j + +) { if(num<B[i]) {T=num; Num=B[i]; B[i]=T; }}} printf ("This array is:"); for(i=0;i<Ten; i++) {printf ("%d\t", B[i]); } }
/*there is an array of {2,5,6,11,15,17,22,34,45}, any integer entered by the user is in the array, if it is not printed without the number, if the number is deleted, and the following numbers are moved forward sequentially, finally with the number 0 to fill the position. For example: User input 22, then the data in the array changes to {2,5,6,11,15,17,34,45,0}*/#include<stdio.h>intMainvoid){ inta[9]={2,5,6, One, the, -, A, the, $}; inti,j; inttmp=0; intnum=0; printf ("there is an array a[9]={2,5,6,11,15,17,22,34,45}\n"); printf ("Please enter a number:"); scanf ("%d",&num); for(i=0;i<9; i++) { for(j=0; j<=i;j++) { if(num==A[j]) {num=0; TMP=num; Num=a[j+1]; A[j+1]=tmp; }} printf ("%d\n", A[j]); } }
/*merges the array {17,82,-4,55} and the group {34,11,66,56,76} into an array, and then sorts the elements in it. Sort by size from large to small. */#include<stdio.h>intMainvoid){ intsum[9]={ -, the,-4, -, the, One, the, About, the}; intI, J; intTMP =0; printf ("This series is arranged from large to small:"); for(i=0;i<9; i++) { for(j=0;j<8; j + +) { if(sum[j]<sum[j+1]) {tmp=Sum[j]; SUM[J]=sum[j+1]; Sum[j+1]=tmp; } } } for(i=0;i<9; i++) {printf ("%d\t", Sum[i]); } }
/*find the sum of the diagonal elements of a 3*3 matrix. */#include<stdio.h>intMainvoid){ intmatrix[3][3]; inti,j; intnum=0; for(i=0;i<3; i++) { for(j=0;j<3; j + +) {printf ("Please enter%d digits (total 9 digits): \ n", i+1); scanf ("%d",&); } } }
817 C Language Jobs