㈠ 这个C程序的目的很简单,计算每年的总降雨量,年平均降雨量,月平均降雨量,编译器没报错,
for(y=0;y<YRS;y++)
		{
			for(m=0;m<MONTHS;m++)
				total+=ar[y][m];
			printf("%d%10.1f\n",1990+y,total);
		}
你要计算每年的total,但是这里的total是不断累加的,每次外循环时应该把total置为0;
下面那个函数也一样
㈡ 如何实现c语言程序各颜色数字雨代码
#include<stdio.h>
#include<time.h>
#include<windows.h>
typedef struct
{
int x,y;
char ch;
}STU;
STU st[100];
//出现位置
void gotoxy(int x, int y)
{
HANDLE hout;
COORD pos;
pos.X = x;
pos.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, pos);
}
/*隐藏光标*/
void show_cursor(int hide)
{
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hout;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hout, &cciCursor))
{
cciCursor.bVisible = hide;
SetConsoleCursorInfo(hout, &cciCursor);
}
}
/*设置颜色*/
void set_color(int color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
main()
{
int i,j;
show_cursor(0);
srand(time(NULL));
//初始化结构体
for (i=0;i<100;i++)
{
st[i].x = rand()%80;
st[i].y = rand()%20;
st[i].ch = rand()%(49-47)+48;
}
while (1)
{
for (i=0;i<100;i++)
{
gotoxy(st[i].x,st[i].y);
set_color(0x2);//最先出现的颜色;
putchar(st[i].ch);
gotoxy(st[i].x,st[i].y-5);
putchar(' ');
st[i].y++;
st[i].ch = rand()%(49-47)+48;
if (st[i].y-5>=18)
{
gotoxy(st[i].x,st[i].y-1);
putchar(' ');
gotoxy(st[i].x,st[i].y-2);
putchar(' ');
gotoxy(st[i].x,st[i].y-3);
putchar(' ');
gotoxy(st[i].x,st[i].y-4);
putchar(' ');
gotoxy(st[i].x,st[i].y-4);
putchar(' ');
}
if (st[i].y > 23)
{
st[i].x = rand()%80;
st[i].y = rand()%20;
}
gotoxy(st[i].x,st[i].y);
set_color(0xA);//由前一个颜色渐变成的颜色
putchar(st[i].ch);
}
Sleep(120);
}
}
color(0);printf("黑色
");color(1);printf("蓝色
");color(2);printf("绿色
");color(3);printf("湖蓝色
");color(4);printf("红色
");color(5);printf("紫色
");color(6);printf("黄色
");color(7);printf("白色
");color(8);printf("灰色
");color(9);printf("淡蓝色
");color(10);printf("淡绿色
");color(11);printf("淡浅绿色
");color(12);printf("淡红色
");color(13);printf("淡紫色
");color(14);printf("淡黄色
");color(15);printf("亮白色
")几个基本的颜色;
㈢ c语言现在正在下雨吗死循环
你好,C语言中,强制终止死循环可以用CTRL+BREAK组合键或者CTRL+C组合键。
命令解释:
CTRL+BREAK 设置或清除 DOS 系统的扩展。CTRL+C 检测这个命令是为了与 DOS 系统的兼容而保留的,在 Windows里不起作用。如果命令扩展被启用,并且操作平台是Windows,BREAK 命令会在被调试程序调试时输入一个硬代码中断点。
通过CTRL+BREAK组合键或者CTRL+C组合键能够实现中断死循环。
㈣ c语言中 4&&5的值为什么是1 4&5的值是多少 逻辑与和按位与有什么区别
4&&5的值为1,这里的1是表示真。因为4和5都是非0值。非0即为真。真真得真。所以结果为1。
4&5的值为4。这里4的二进制是shu“100”,5的二进制是“101”。
按位与就是100&101=100(即十进制为4);
&&是逻辑运算符,两个结果中有一个0结果才是0,比如0&&1,结果是0;1&&0,结果也是0。还有一个&是位运算符。

(4)c语言编程模拟下雨扩展阅读:
在形式逻辑中,逻辑运算符或逻辑联结词把语句连接成更复杂的复杂语句。例如,假设有两个逻辑命题,分别是“正在下雨”和“我在屋里”,我们可以将它们组成复杂命题“正在下雨,并且我在屋里”或“没有正在下雨”或“如果正在下雨,那么我在屋里”。一个将两个语句组成的新的语句或命题叫做复合语句或复合命题。
㈤ 怎么用c写 下雨或下雪的 程序
初始化
void Init_Data()
{
 int i;
 for( i=0; i< POINT; i++)
 {
  Snow[i].x=0;
  Snow[i].y=0;
  Snow[i].size=0;
 }
 for( i=0; i<MaxX; i++)
  Map[i]=MaxY;
}
显示:
void MakeSnow()
{
 int i;
 if( CurSnow>=POINT ) return;
 for( i=0; Snow[i].size; i++ )
  ;
 CurSnow++;
 Snow[i].x=random(MaxX);
 Snow[i].y=random(DOWNSPEED);
 Snow[i].size=random(MaxSize)+1;
 
}
设定显示坐标
void ShowSnow( int x, int y, int size, int flag )
{
 int color=0;
 if ( flag ) color=15;
 switch( size )
 {
 case 1:
  putpixel( x, y, color );
  break;
 case 2:
  setcolor( color );
  line( x-1, y-1, x+1, y+1 );
  line( x-1, y+1, x+1, y-1 );
  break;
 case 3:
  setcolor( color );
  line( x-1, y-1, x+1, y+1 );
  line( x-1, y+1, x+1, y-1 );
  /*
  line( x-2, y-2, x+2, y+2 );
  line( x-2, y+2, x+2, y-2 );*/
  line( x-2, y, x+2, y );
  line( x, y-2, x, y+2 );
  break;
 }
}
雪花移动效果:
void Move( int n, int tox, int toy )
{
 int x, y, size, i, j;
 float person;
 x=Snow[n].x;
 y=Snow[n].y;
 size=Snow[n].size;
 /* check end */
 j=y;
 if( x<tox )
 {
  person=(DOWNSPEED *1.0) / ( tox-x )*1.0;
  for( i=x; i<=tox; i++ )
  {
   if( j>=Map[i] ) 
   {
    tox=i-size;
    break;
   }
   j+=(int)( (i-x+1)*person );
  }
 }
 else if( x>tox )
 {
  person=(DOWNSPEED *1.0) / ( x-tox )*1.0;
  for( i=x; i>=tox; i-- )
  {
   if( j>=Map[i] )
   {
    tox=i+size;
    break;
   }
   j+=(int)( (x-i+1)*person );
  }
 }
 
 if( y+DOWNSPEED>=Map[tox] )
 {
  switch( size )
  {
  case 1:
   Map[x]--;
   break;
  case 2:
   Map[x]-=2;
   if( x>0 && Map[x-1]>Map[x] ) Map[x-1]=Map[x];
   if( x<MaxX-1 && Map[x+1]>Map[x] ) Map[x+1]=Map[x];
   break;
  case 3:
   Map[x]-=3;
   if( x>1 && Map[x-2]>Map[x] ) Map[x-1]=Map[x];
   if( x>0 && Map[x-1]>Map[x] ) Map[x-1]=Map[x];
   if( x<MaxX-2 && Map[x+2]>Map[x] ) Map[x+1]=Map[x];
   if( x<MaxX-1 && Map[x+1]>Map[x] ) Map[x+1]=Map[x];
   break;
  }
  CurSnow--;
  y=Map[x]+size;
  Snow[n].x=x;
  Snow[n].y=y;
  Snow[n].size=0;
 }
 else /* not end */
 {
  Snow[n].x=tox;
  Snow[n].y=toy;
 }
}
㈥ C语言编写程序
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
intmain()
{
inttemperature;//温度
intweather;//天气
charstr_weather[5];
intwind;//风
srand((unsigned)time(0));//初始化随机种子
temperature=rand()%63-20;//获取-20到42的随机数
while(1)
{
weather=rand()%3;//获取天气情况:0为雨,1为雪,2为晴
if(temperature<0&&weather==0)//如果温度小于0度并且天气为雨,则重新获取
{
continue;
}
switch(weather)
{
case0:
strcpy(str_weather,"雨");
break;
case1:
strcpy(str_weather,"雪");
break;
case2:
strcpy(str_weather,"晴");
break;
}
break;//如果符合规则,则退出循环
}
wind=rand()%13;//获取风级:0-12
printf("今天温度:%d天气:%s风级:%d级 ",temperature,str_weather,wind);
return0;
}
