48 date:2021.3.16
要点:
详细代码如下:
#include <stdio.h>
#define N 4
void fun(int (*t)[N])
{
int i, j, x;
/**********found**********/
for(i=0; i<N; i++)
{
/**********found**********/
x=t[i][N-1] ; //赋初值
for(j=N-1; j>=1; j--)
t[i][j]=t[i][j-1];
/**********found**********/
t[i][0]=x; //将原来的最后一列元素放入最左边,第一列元素列下标为0
}
}
void main()
{
int t[][N]={
21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10}, i, j;
printf("The original array:\n");
for(i=0; i<N; i++)
{
for(j=0; j<N; j++) printf("%2d ",t[i][j]);
printf("\n");
}
fun(t);
printf("\nThe result is:\n");
for(i=0; i<N; i++)
{
for(j=0; j<N; j++) printf("%2d ",t[i][j]);
printf("\n");
}
}
要点:
详细代码如下:
#include <conio.h>
#include <stdio.h>
double fun(double q)
{
int n;
double s,t;
n=2;
s=2.0;
while (s <= q)
{
t=s;
/********found*********/
s=s+ (double)(n+1)/n; //必须进行类型转换
n++;
}
printf("n=%d\n",n);
/********found********/
return t; //要求返回小于q的值,所以不是return s;
}
void main ( )
{
printf("%f\n",fun(50));
}
要点:
详细代码如下:
#include <math.h>
#include <stdio.h>
int fun( int t)
{
// 求数列中大于 t 的最小数 并返回结果
//后一项等于前两项的和
int f0 = 0, f1 = 1,f = 0;
do{
f = f0 +f1; //f :前两项的和
f0 = f1; // f0 : 第n-2项
f1 = f; //f1 : 第n-1项
}while(f <= t);
return f;
/* EROOR:while循环不行?
while( f <= t)
{
f = f0 + f1;
f1 =f;
f0 = f1;
}
return f;
*/
}
void main() /* 主函数 */
{
int n;
void NONO ( );
n=1000;
printf("n = %d, f = %d\n",n, fun(n));
NONO();
}