#include <stdio.h>#define N 30int main () {FILE *fp=null;char file_name[n];IntS,a=0,l=0; printf ( "Please enter the file name to be counted: \ n"); scanf ( "R"); while ((s=fgetc (FP))!=eof) {if ( S==s;} fclose (FP); if (A!=else if (s!= s!= '//') {l--;} printf ( "total%d rows \ n", l); return 0;}
I will study hard, write code, and try to complete 5000 lines of code.
4. Having learned C, how do you copy the contents of array A into array B? How do I find the number 5 in an integer array a? How do I sort an integer array a (small to large, from large to small)? Write the appropriate program.
Copy
#Include<stdio.h>#define N 5int main () {int A[N]; int b[n]; int i; printf ( "Input b array number: \ n"); 0;i<n;i++) {scanf ( "%d" , &b[i]);} for (I=0;i<n;i++) {a[i]=b[i];} printf ( "contents of output array a \ n"); 0;i<n;i++) {printf ( "%d ", B[i]);}
Find
#Include<stdio.h>#Define N 10IntMain(){int a[n];int i,j=0; printf ("Please enter a number (enter 0 to end): \ n"); For (i=0;i<n;i++) { scanf ("%d", &a[i]); if (a[i]==0) {break ;}} printf ("Find out if there is a digital 5:\n"); For (i=0;i<n;i++) { if (a[i]==5) {j + +;}} if (j=1)printf ("exists"),elseprintf ("does not Exist");}
Sort
#include <stdio.h>#define N 10void Main () {int A[n],flag;int i,j,temp;printf"Please input%d numbers\n". N);for (I=0;i<n;i++) {scanf ( "%d", &a[i]); }printf ( "\ n"); 1;i<n;i++) {iflag=0; for (J=0;j<n-i;j++) {if (A[j] >a[j+1]) {temp=a[j]; A[j]=a[j+1]; a[j+ 1]=TEMP; Iflag=1;} if (Iflag==0) {break;}} printf (the array of order is: \n", A[i]);}}