c++编程题不会写啊? 大一c语言编程题库
C语言编程题目不会做,求帮忙
代码如下:
#include <stdio.h>
#include <stdlib.h>
int main(){
int a[11]; //这里声明数组有11个元素存放空间,最后一个空间即a[10]用来存放找不到的X数。因为数组下标范围是0~10,所以a[10]是最后一个。
int i,x; //i变量用来搞循环,x变量用来输入X数。
for(i=0,i<10,i++) {
srand((unsigned)time(NULL)); //让随机数随时间重新播种,每次产生随机数都不一样。
a[i]=rand()%51; //每次循环会产生一个 0~50 的随机数赋值给数组。
}
printf("请输入要查找的数,按回车键结束输入\n");
scanf("%d ",&x);
for(i=0,i<10,i++) {
if(x==a[i])printf("随机数中找到该数:%d\n",x);
else {a[10]=x; printf("找不到该数,已存放到数组的最后);}
}
return 0;
}
C语言编程题不会做啊
#include
#include
void main()
{
int n,a,b,bTemp;
int *p;
printf("how many numbers?\n");
scanf("%d",&n);
p=malloc(sizeof(int)*n);
printf("please input the numbers.\n");
for(a=0;a { scanf("%d",(p+a)); } for(b=0;b { for(a=0;a { if(*(p+a)>*(p+a+1)) { //互换 bTemp = *(p+a); *(p+a) = *(p+a+1); *(p+a+1) = bTemp; } } } for(a=0;a { printf("%d ",*(p+a)); } printf("\n"); free(p); } vc6.0下调试通过。 #include struct student { int tNum; char tName[10]; float score[3]; }; void Input( struct student *h, int n) { h=NULL; student *p; for(int i=0;i { p=malloc(sizeof(student)); scanf("%d%s",&(p->tNum),&(p->tName)); for(int i=0;j<3;j++) scanf("%f",&(p->score[j])); if(i==0) h=p; p++; } } void Total1( struct student *p, int *psum, float *pave, int n) { for(int i=0;i { *psum=0; for(int j=0;j<3;i++) *psum=*psum+p->score[j]; *pave=*psum/3; psum++; pave++; p++; } } void Print( struct student *p, int *psum, float *pave, int n); { int i=0,j; printf( "Pos\tNum\tName\t\tEng\tCom\tMath\tSum\tAver\n"); for(i=0;i { printf( "%d\t%ld\t%s\t",i,p->tnum,p->tname); for(j=0;j<3;j++) printf("%d\t",p->score[j]); print("%d\t%.1f\n",*psum,*ave); p++; psum++; pave++; } } /article.c -- 有一篇文章,共有3行文字,每行有80个字符。要求分别统计出其中英文大写字母,小写字母,数字。空格以及其他字符的个数 #include #define N 3 int main (void) { char a[N][80] = { {"Hello, my name is Ann. I'm taking an American accent training."}, {"And I have paid $ 100. I think I can do it. So insist it."}, {"Now I am making a programming and I want to mannage it."} }; int x, b, c, d, e, i , j; x = b = c = d = e = 0; for (i = 0; i < N; i++) { for (j = 0; j < 80; j++) { if (a[i][j] >= 65 && a[i][j] <= 90) x++; else if(a[i][j] >= 97 && a[i][j] <= 122) b++; else if(a[i][j] >= 48 && a[i][j] <= 57) c++; else if (a[i][j] == 32) d++; else e++; } } printf ("This article has %d 大写字母,%d 小写字母,%d数字,%d空格 和%d其他字符", x, b, c, d, e); return 0; }c语言编程题。。不会做求大神
C语言编程题,小白不会编程序