‘壹’ 紧急!c语言多个数组问题!!!
#include<stdio.h>
int main()
{
int i,j = 0,a[7],b[7],c[7],max;
//1.声明的数组最好初始化
for(i = 0;i < 7;i++)
{
a[i] = 0;
b[i] = 0;
c[i] = 0;
}
//2.界面可以人性化一点,方便自己和别人使用
//以下是输入数据
for(i = 0;i < 7;i++)
{
printf("Day.%d\n",i+1);
scanf("%d%d",&a[i],&b[i]);
c[i]=a[i]+b[i];
printf("StudyTime:%d\n",c[i]);
}
//3.功能模块也可以分清楚一点,不必一下子把什么事情都做完
//以下是分析比较数据,和你的不太一样,我用MAX来存储最大的数据,用J来记录最忙的日子
//个人认为这样的程序更加易读
max = c[0];
for(i = 0;i < 7;i++)
{
if(max < c[i])
{
max = c[i];
j = i;
}
}
printf("\n");
//最后的输出没按题目要求来,用了人性化的输出。
if(max<=8)
printf("A Happy Week^^\n%d",0);
else
printf("The Busy Day is:%d\n Her study time is:%d\n",j, max);
return 0;
}
/*感觉像电子宠物o(∩_∩)o...建议编程的时候层次清楚一点,易读性是相当重要的哦*/
‘贰’ 用c语言编程,各位大虾帮帮忙
#include<stdio.h>
void main()
{
int hour,week;
int money;
float tax;
printf("请输入星期与工作时间:");
scanf("%d%d",&hour,&week);
switch(week)
{
case 1:
money=20*hour;
break;
case 2:
money=20*hour;
break;
case 3:
money=20*hour;
break;
case 4:
money=20*hour;
break;
case 5:
money=20*hour;
break;
case 6:
money=20*hour*3;
break;
case 7:
money=20*hour*3;
break;
}
tax=(float)0.08*money;
printf("该日的税前工资为:%d\n",money);
printf("税金为:%.2f\n",tax);
}
‘叁’ c语言 指针数组打印星期一到星期日
# include <stdio.h>
void printstr(char **p);
int main()
{
char i;
char str[100];
char *num[]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
char **p;
p=num;
// printf("请输入1到7之间的数字 ");
printstr(p);
}
void printstr(char **p)
{
char i;
_start:
printf("请输入1到7之间的数字 ");
fflush(stdin);
scanf("%c", &i);
if(Ƈ'<=i && i<=ƍ')
printf("%s i=%d ",*(p+i-49),i);
//**************************************************************
if(i<Ƈ')
printf("*输入错误!i=%d ",i);
//***********************************************************
if(i>ƍ' && i!='a')
printf("**输入错误! ");
if(i=='a')
{
printf("程序结束了 ");
return;
}
goto _start;
}
10是换行字符'
'的ascii码。用scanf读取字符的时候,敲的回车回遗留在缓存里,下次再调用scanf读取字符时,会把这个'
'读出来,就不会再要求键盘输入了。
另外,每次输出后,又递归调用,这样随着输入次数的增加,递归会越来越深,很容易导致栈溢出。
‘肆’ C语言 编写一个程序 输入周几号 输出改天的英文名 要求用指针处理
1 定义字符串指针数组,指向7个英文单词,分别为周一到周日。
2 输入周几号。
3 取出对应的英文单词并输出。
代码:
intmain(void)
{
intn;
char*week[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
scanf("%d",&n);
puts(week[n-1]);
return0;
}
‘伍’ 用c语言编写一程序实现如下功能:输入1、2、3、4、5、6、70(分别对应星期一至
用蔡勒公式即可:
#include<stdio.h>
intmain()
{
inty,m,d,c,w;
printf("输入年月日(空格间隔):");
scanf("%d%d%d",&y,&m,&d);
if(m==1||m==2)
{//判断月份是否为1或2y--;m+=12;}
c=y/100;
y=y-c*100;
w=(c/4)-2*c+(y+y/4)+(13*(m+1)/5)+d-1;
while(w<0)w+=7;
w%=7;
if(w==0)printf("星期日");
elseprintf("星期%d",w);
return0;
}
方法二:
#include
void main ()
{
int y,m,d,c,s,w;
printf("请输入8位年月日,以空格隔开:");
scanf("%d%d%d",&y,&m,&d);
if (m==1) c=d;
else if (m==2) c=31 d;
else if (m==3) c=31 28 d;
else if (m==4) c=31 28 31 d;
else if (m==5) c=31 28 31 30 d;
else if (m==6) c=31 28 31 30 31 d;
else if (m==7) c=31 28 31 30 31 30 d;
else if (m==8) c=31 28 31 30 31 30 31 d;
else if (m==9) c=31 28 31 30 31 30 31 31 d;
else if (m==10) c=31 28 31 30 31 30 31 31 30 d;
else if (m==11) c=31 28 31 30 31 30 31 31 30 31 d;
else if (m==12) c=31 28 31 30 31 30 31 31 30 31 30 d;
if (m>2)
{if (y0==0) {if (y@0==0) c=c 1;}
else if (y%4==0) c=c 1;}
s=(y-1)*365 (y-1)/4-(y-1)/100 (y-1)/400 c;
w=s%7;
switch (w)
{
case 0: printf("星期日");break;
case 1: printf("星期一");break;
case 2: printf("星期二");break;
case 3: printf("星期三");break;
case 4: printf("星期四");break;
case 5: printf("星期五");break;
case 6: printf("星期六");break;
printf("");
}
}
‘陆’ C语言新手求助,想输入a,b....g,依次显示周一到周日,为何编译正确,执行就错误错误在哪儿
switch(‘c’)改为switch(c),并且case'g':后面应为printf,
如果你用的是vc++6.0编译的话最好再包含上头文件#include<string.h>。这样我感觉就行啦。
‘柒’ 编写程序,输入周一至周五中的任意一天,屏幕显示一条不同的短语,短语内容自拟。c语言
#include <stdio.h>
int main()
{
int day=0;
printf("输入星期几(要求输入1—7中的一个整数,例如星期六,输入 6)\n");
scanf("%d",&day);
switch(day)
{
case 1:printf("星期一快乐!");break;
case 2:printf("星期二快乐!");break;
case 3:printf("星期三快乐!");break;
case 4:printf("星期四快乐!");break;
case 5:printf("星期五快乐!");break;
case 6:printf("星期六快乐!");break;
case 7:printf("星期日快乐!");break;
default:printf("跟你说了要输入1—7中的一个整数");break;
}
printf("\n");
return 0;
}
‘捌’ C语言编程输入数字1到7 分别输出周一到周日的英文单词
//这个就不用注释了吧#include "stdio.h"void main(){ int i; printf("输入1~7其中一个数字:"); scanf("%d",&i); switch(i) { case 1: printf("Monday\n");break; case 2: printf("Tuesday\n");break; case 3: printf("Wednesday\n");break; case 4: printf("Thursday\n");break; case 5: printf("Friday\n");break; case 6: printf("Saturday\n");break; case 7: printf("Sunday\n");break; default: printf("April Fools' Day\n");break; }}‘玖’ c语言输出字母星期一到星期日
#include<stdio.h>
enumweekday{
MON=1,TUE,WIN,THE,FRI,THI,SUN
};
intmain(intargc,char*argv[]){
inti;
charday[][3]="{MON},{TUE},{WIN},{THE},{FRI},{THI},{SUN}";
for(i=MON;i<=SUM,i++)
printf("%s ",day[MON-1][0]);
return0;
}
//不懂追问
‘拾’ C语言程序设计求助,求设计一个程序,要求输入1-7的整数,对应输出星期一~星期天,最好附上思路,谢谢
#include<stdio.h>void main()
{
int i;
printf("请输入1-7数字 ");
scanf("%d",&i);
switch(i)
{
case 1: printf("今天星期一");break;
case 2: printf("今天星期二");break;
case 3: printf("今天星期三");break;
case 4: printf("今天星期四");break;
case 5: printf("今天星期五");break;
case 6: printf("今天星期六");break;
case 7: printf("今天星期天");break;
}
}
switch语句应该学了吧 直接用switch语句进行选择就行了 运行结果: