barriers / 阅读 / 详情

C程序:输入若干字符,分别统计数字字符的个数、英文字母的个数,当输入换行符时输出统计结果,运行结束。

2023-07-08 00:11:35
共2条回复
慧慧

#include "stdio.h"

void main()

{

char s;

int i=0,j=0,k=0,m=0,da=0,xiao=0;

printf("please input the string ");

while((s=getchar())!=" ") /*循环从键盘读入字符直到一行结束(输入回车)*/

{

if((s<="z"&&s>="a")||(s<"Z"&&s>"A"))

{

if(s<="Z"&&s>="A")da++;

if(s<="z"&&s>="a")xiao++;

i++; /*i存入字母数*/

}

else if(s==" ") j++; /*j存入空格数,注意s==" "里面是有一个空格的*/

else if(s<58&&s>47)k++; /*k存入数字数*/

else m++; /*m存入其它符号数*/

}

printf("char:%d Capital letters:%d Lowercase%d spec:%d number:%d Other:%d ",i,da,xiao,j,k,m); /*打印行中的字母,空格,数字,其它字符数*/

}

CarieVinne

输入用gets,然后分别判断各字符在"0"-"9"之间,还是在"a"-"z"或"A"-"Z"之间

相关推荐

服务器server0处于不兼容的状态怎么办

控制台启动server时报"对于服务器server-1与计算机machin对于服务器AdminServer, 与计算机Machine-0相关联的节点管理器无法访问。所有所选服务器当前都处于与此操作不兼容的状态, 或未与运行的节点管理器关联, 或没有授权您执行请求的操作。不会执行任何操作次错误基本都遇到过。在网上搜了半天,最后才解决,基本如下:对于服务器server-1与计算机machine-2相关联的节点管理器无法访问。所有所选服务器当前都处于与此操作不兼容的状态, 或未与运行的节点管理器关联, 或没有授权您执行请求的操作。不会执行任何操作。原因:nodemanager没有启起来一、对于managedServer于adminServer在同一服务器上的情况:1、在控制台可查看该机器的节点管理器端口,比如为55562、用netstat -nap | grep 5556命令查看端口为5556的进程是否存在便知nodemanager是否已启动,这时肯定是不存在的3、但是用ps -ef |grep java命令查看进程,可看到NodeManager进程4、用kill -9 NodeManager进程号5、vi /etc/hosts查看ip地址配置是否正确6、vi /etc/sysconfig/network查看机器名配置是否正确7、vi $WL_HOME/common/nodemanager/nodemanager.properties查看以下配置是否正确,这里的端口5556就与上文提到的端口一致,如果端口不对可能是因为在前一次nodemanager起来之后,在控制台修改了端口,而在nodemanager.properties文件中保存的还是原端口,所以当再次启动nodemanager时,启动的端口不是修改后的而是原来的。ListenPort=5556SecureListener=falseStartScriptEnabled=true二、如果AdminServer在服务器A上,ManagedServer在服务器B上的情况:这时候不能启动nodemanager还可能是因为服务器B无法与服务器A通讯,这时候会报socket相关错误。此时,1、在B服务器上修改$WL_HOME/common/nodemanager/nodemanager.properties文件:SecureListener=falseStartScriptEnabled=true2、在B上$WL_HOME/common/bin/目录下执行wlst.sh脚本./wlst.sh即可3、执行完2后会来到wls:/offline>下,在此输入connect()回车4、此时会依次要求输入AdminServer的用户名、密码及url如下Please enter your username [weblogic] :weblogicPlease enter your password [weblogic] :Please enter your server URL [t3://localhost:7001] :t3://adminServerIP:port以上三项指服务器A上登录控制台时的用户名、密码及IP地址和端口5、如果第4步执行成功,则显示Successfully connected to Admin Server "AdminServer" that belongs to domain "my_domain".会跳到wls:/my_domain/serverConfig>my_damain指服务器A上的domain如果第4步执行不成功,会返回第3步重新输入connect()此时也可输入dumpStack()回车,查看具体错误6、第5步执行成功后,在wls:/my_domain/serverConfig>下依次执行nmEnroll("/home/weblogic/Oracle/Middleware/wlserver_10.3/common/nodemanager")nmEnroll("/home/weblogic/Oracle/Middleware/user_projects/domains/server_b_domain")这里的weblogic目录指服务器B上的weblogic目录,视自己的目录修改语句。7、注册成功后,按ctrl+c返回weblogic目录,再到$WL_HOME/servers/bin目录下nohup ./startNodeManager.sh &启动nodemanager如果启动时报以下错误严重: Fatal error in node manager serverjava.net.BindException: Address already in useat java.net.PlainSocketImpl.socketBind(Native Method)at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)at java.net.ServerSocket.bind(ServerSocket.java:319)at java.net.ServerSocket.(ServerSocket.java:185)at weblogic.nodemanager.server.Listener.init(Listener.java:54)at weblogic.nodemanager.server.NMServer.start(NMServer.java:205)at weblogic.nodemanager.server.NMServer.main(NMServer.java:355)at weblogic.NodeManager.main(NodeManager.java:31)说明前面以执行过该语句,此时需要杀掉nodemanager的进程号再次执行启动语句。补充:节点管理器类型可选择"普通"。
2023-07-07 20:47:173

System.UnauthorizedAccessException

你上传后的图片展示应该用上传后的网络路径,比如:"http://www.yourdamain.com/photo/20100120091326.jpg",而不是用"E:webjob0231personpersonPhoto20100120091326.jpg"这样的本地路径。因为在网络应用程序对本地图片没有访问权限。 -----------------------------------------------------------当你保存的时候,相当于服务端的内部逻辑,所以用FileUpload1.PostedFile.SaveAs(Server.MapPath("../person/personPhoto/" + filename));是没错的。但当从客户端打开网络应用程序时,调用的路径是相对于客户端的,比如"E:webjob0231personpersonPhoto20100120091326.jpg",这被认为是客户端的路径,和你直接在浏览器上键入这个地址是一样的效果,打开的是本地文件而不是服务端文件。所以在面向客户端的时候,比如展示图片,必须用网络路径。
2023-07-07 20:47:371

汇编语言的HIGH和LOW指令怎么用

DA1是你定义的变量,变量是不可以用HIGH和LOW操作的!
2023-07-07 20:47:453

Is That You? 歌词

歌曲名:Is That You?歌手:Bill Frisell专辑:Is That You?Bow Wow - Is That You (P.Y.T)Im Looking for thatpretty young thangup in the spot, looking hot playin` no gamesAnd she steady tryina get it crunk right from the jumpand she playin` no games.that you Shawty? (yea thats me)Did you come here to party? (Yes indeed)Ha But could you drop it down lowwhen its time to get lowif so baby girl lets go.(Come and get it boy)They say I act old, but I got that old man gameCause I stay tryina find me a pretty young thangthat I call anytime if she ready to hangand if sun"it jump off she be ready to bangI like `em fresh outta high schooljust about to graduate short shirtsed`day tryina show they little shapelow cut jump jeans lugz on hea feetneighborhood girl but she love the streetsIn a party she da main one doin dat right thurrEv"time hea jam drop hands up in the airr.And she aint thinkin you, she aint thinkin bout hea hurrAnd if you ballin homie she dont even really currShe got her mind set on what she wanna doAnd she aint come alone she got her whole little crew.Her P.Y.T"s that"ll make ya head spinEry nigga in the club tryina get inIm Looking for thatpretty young thangup in the spot, looking hot playin` no gamesAnd she steady tryina get it crunk right from the jumpand she playin` no games.that you Shawty? (yea thats me)Did you come here to party? (Yes indeed)Ha But could you drop it down lowwhen its time to get lowif so baby girl lets go.(Come and get it boy)They got a whole lot of attituderap is all that they listen tostays in the sweet tryina find somthin newcustom ipods with the rhinestonesnextel camara phones with all the hot ringtones.Light skin til black little PYT"sboricua mami"s that like to eat Mickey D"salways into sumthin like NWAgota little bittie frame but home she dont playYou know a gyrl is the reason that a nigga wanna stuntAnd im weak for em homie I aint even gon frontSee most young nigga"s like em oldernot me spot they spot me like in the summerI run up hit them with that Moss A gamelike "Baby wuz ya phone numba? Were ya live at?Shawdy what part of town? Cuz I just wanna be down!"Im Looking for thatpretty young thangup in the spot, looking hot playin` no gamesAnd she steady tryina get it crunk right from the jumpand she playin` no games.that you Shawty? (yea thats me)Did you come here to party? (Yes indeed)Ha But could you drop it down lowwhen its time to get lowif so baby girl lets go.(Come and get it boy)Pretty Young Thang repeat after mesay Nah nanana "Nah nanana"Nah nanana "Nah nanana"say pretty young thangs repeat after mesay Nah nanana "Nah nanana"Nah nanana "Nah nanana"Im Looking for thatpretty young thangup in the spot, looking hot playin` no gamesAnd she steady tryina get it crunk right from the jumpand she playin` no games.that you Shawty? (yea thats me)Did you come here to party? (Yes indeed)Ha But could you drop it down lowwhen its time to get lowif so baby girl lets go.(Come and get it boy)http://music.baidu.com/song/1061230
2023-07-07 20:47:521

c语言输入一串字母 输出字母数字 其它字符的个数

对于这个问题,不需要存到数组。按照如下流程即可:1 输入一个字符,对该字符进行判断:a) 如果是数字,则数字累加器加一。b) 如果是字母,则字母累加器加一。c)如果是换行,则结束统计(以换行为结束符。如需其他结束符,根据需要更改判断)。2输出结果。代码:#include <stdio.h>int main(){int c, n, i;c=n=0;while(1){i = getchar();if(i>="0" && i <= "9") n++;else if((i>="a" && i <= "z")||(i>="A" && i <= "Z"))c++;else if(c==" ") break;}printf("数字%d个,字母%d个 ", n,c);return 0;}
2023-07-07 20:48:021

题目如下 #includestruct s {int a,b;} data[2]=10,100,20,200}; main() { struct s p=da...

struct s {int a,b;} data[2]={10,100,20,200}; 定义了一个数组,data[1]中的a未20b为200然后p=a[1],把a[1]的值赋给p
2023-07-07 20:48:092

C语言编程代码

#include<stdio.h>int main(){ int date=0,da=0,xiao=0; char c; c=getchar(); while(c!="!") { if(c>="a"&&c<="z") xiao++; if(c>="A"&&c<="Z") da++; if(c>="0" &&c<="9") date++; c=getchar(); // 输入多个字符} printf("xiao=%d,da=%d,date=%d ",xiao,da,date); return 0;}
2023-07-07 20:48:205

数据集合处理(c++处理)

/*要求:1.集合元素不超过100个。2.集合用数组表示(数组预先定义大一些)。功能有:1.程序初始运行时任意输入一批初始数放入集合(可少可多,不少于5个,不超过30个)。2对该批数排序存放。程序完成前两步后,通过循环可以不断选择下面的某项功能执行(用提示语句列出菜单,通过读入某变量值,switch判断该变量,如接受到1表示执行第一项,依次类推,某项功能执行完可以返回菜单,也可退出系统):3.任意插入一个数到排好序的集合中,保持集合依然有序。4.在集合中删除一个元素。5.查询某个值是否在集合中(该数由键盘输入)。6.求出该数据集合的最大值和最小值及所在位置。7.找出数据集合中的所有素数。*/#include<iostream.h>#include<windows.h>/*charmenu[][100]={" **************************************","请选择操作:","1:输出现有数据;","2:插入一个数据;","3:删除一个数据;","4:查找指定数据;","5:找出数组中最大值","6:找出数组中最小值;","0:退出","*************************************** "};*/charmenu[]=" *************************************** 请选择操作: 1:输出现有数据; 2:插入一个数据; 3:删除一个数据; 4:查找指定数据; 5:找出数组中最大值; 6:找出数组中最小值; 0:退出。 *************************************** ";classArry{private:intarry[110];intnum;public:Arry();//用随机产生的数初始化数组并排序voidInsert(intia);//插入一个数voidShow();//输出现有数组voidDelete(intda);//删除指定的数voidFind(intfa);//查找指定的数voidFindMax();//找出最大数voidFindMin();//找出最小数};Arry::Arry(){num=30;inttemp=0;for(inti=0;i<110;i++)if(i<30)arry[i]=rand()/100;elsearry[i]=0;for(i=0;i<num-1;i++)for(intj=0;j<num-i-1;j++)if(arry[j]>arry[j+1]){temp=arry[j];arry[j]=arry[j+1];arry[j+1]=temp;}}voidArry::Insert(intia){inti=0;if(arry[0]>=ia){for(intj=num;j>0;j--)arry[j]=arry[j-1];arry[0]=ia;num++;}else{while(arry[i]<ia&&i<num)i++;for(intj=num;j>i;j--)arry[j]=arry[j-1];arry[j]=ia;num++;}}voidArry::Show(){cout<<"现有数据为: ";for(inti=0;i<num;i++){cout<<arry[i]<<" ";if((i+1)%5==0)cout<<endl;}cout<<endl;}voidArry::Find(intfa){intf=0;for(inti=0;i<num;i++)if(arry[i]==fa){f=1;cout<<"数组中第"<<i+1<<"个数是";cout<<arry[i]<<endl;}if(f==0)cout<<"数组中没有找到指定的数!"<<endl;}voidArry::Delete(intda){ints=0;for(inti=0;i<num;i++)if(arry[i]==da){for(intj=i;j<num-1;j++)arry[j]=arry[j+1];arry[j]=0;i--;num--;s++;}if(s)cout<<"删除了"<<s<<"个数据!"<<endl;elsecout<<"数组中没有找到指定的数!"<<endl;}voidArry::FindMax(){intp=0;intmax=arry[0];for(inti=1;i<num;i++)if(arry[i]>=max){max=arry[i];p=i;}cout<<"数组中最大数据是:"<<max<<endl;cout<<"在数组中的位置是第"<<p+1<<"个"<<endl;}voidArry::FindMin(){intp=0;intmin=arry[0];for(inti=1;i<num;i++)if(arry[i]<=min){min=arry[i];p=i;}cout<<"数组中最小数据是:"<<min<<endl;cout<<"在数组中的位置是第"<<p+1<<"个"<<endl;}voidmain(){Arrya;intchoice=0;intdata=0;while(1){//for(inti=0;i<10;i++)//cout<<menu[i]<<endl;cout<<menu;cin>>choice;switch(choice){case0:exit(1);break;case1:a.Show();break;case2:cout<<"输入要插入的数据:";cin>>data;a.Insert(data);break;case3:cout<<"输入要删除的数据:";cin>>data;a.Delete(data);break;case4:cout<<"输入要查找的数据:";cin>>data;a.Find(data);break;case5:a.FindMax();break;case6:a.FindMin();break;default:cout<<"操作错误! ";break;}}}
2023-07-07 20:48:373

c语言:输入十个数,求最大值,最小值,平均值

以下是一个简单的 C 语言程序,可以用于输入十个数,并求出它们的最大值、最小值和平均值:```c#include <stdio.h>int main() { int i; double sum = 0.0, max, min, num; // 输入第一个数,并将其作为最大值和最小值的初始值 printf("请输入第1个数: "); scanf("%lf", &num); max = min = num; sum += num; // 循环输入剩余9个数,并更新最大值、最小值和总和 for (i = 2; i <= 10; i++) { printf("请输入第%d个数: ", i); scanf("%lf", &num); if (num > max) { max = num; } if (num < min) { min = num; } sum += num; } // 输出结果 printf("最大值为: %.2f ", max); printf("最小值为: %.2f ", min); printf("平均值为: %.2f ", sum / 10); return 0;}```在这个程序中,我们使用了一个 `for` 循环来输入十个数,并分别更新最大值、最小值和总和。需要注意的是,我们在循环开始时已经输入了第一个数,并将其作为最大值和最小值的初始值。最后,我们输出计算得到的最大值、最小值和平均值。需要注意的是,在计算平均值时,我们使用了总和除以10的方式来求解,因为本程序中输入了恰好十个数。如果输入的数目不是十个,应该相应地调整计算平均值的方式。
2023-07-07 20:48:473

程序运行中da变量精度不够,后面总是0.0000

没什么问题啊,除了 第7行 // int ;
2023-07-07 20:49:072

编写函数求出二维整型数组中元素的最大值及其下标号。

//你的错误太多,给你个新的#include<stdio.h>#include<stdlib.h>void da(int a[][4],int n){int i,j,row=0,col=0,max=a[0][0];for(i=0;i<n;i++)for(j=0;j<4;j++){if(a[i][j]>max){max=a[i][j];row=i;col=j;}}printf("最大值:a[%d][%d]=%d ",row,col,max); }int main(){int i,j,n,a[10][4];scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<4;j++)scanf("%d",&a[i][j]);da(a,n);return 0; }
2023-07-07 20:49:173

单片机汇编程序实现DA转换,用DAC0832芯片实现

这是一个仿真实例,可以参考一下,试试。
2023-07-07 20:49:383

关于单片机DA指令

正确答案,可见:http://zhidao.baidu.com/question/151649564
2023-07-07 20:49:462

51低端单片机没有PWM,怎么用DA做呼吸灯???

AD呼吸灯是什么?如果需要51输出PWM的话可以使用定时器,里89C52为例推荐是定时器T2作为发生器,可以作为ADC0809这样AD的工作频率
2023-07-07 20:49:542

我想知道单片机的蜂鸣器音乐程序中断是如何响应的?从main主程序中如何到中断程序?具体步骤是啥?谢谢!

挺简单啊,时间一到就进入中断,中断完再回到主程序
2023-07-07 20:50:032

C++实现:6.编写程序,统计文本文件中大写英文字母,小写英文字母和数字的个数。

#include<stdio.h>#include<stdlib.h>#define NULL 0void main(){FILE *fp1=NULL,*fp2=NULL;int xiao=0,da=0,shu=0,all[26],i;char ch;fp1=fopen("你要读取的文本名字.txt","r");//要把你要读取的文本放在程序所在的地方fp2=fopen("你想要保存位的文本的名字.txt","w");if(fp1==NULL) { printf("Can not open "); exit(0); }if(fp2==NULL) { printf("Can not open "); exit(0); }for(i=0;i<26;i++) all[i]=0;ch=fgetc(fp1);while(ch!=EOF) { if((ch>=65)&&(ch<=90)) { da++; all[ch-65]++; } else if((ch>=97)&&(ch<=122)) { xiao++; all[ch-97]++; } else if((ch>=48)&&(ch<=57)) { shu++; } ch=fgetc(fp1); }printf("小写字母个数为%d 大写字母个数为%d 数字个数为%d ",xiao,da,shu);fprintf(fp2,"小写字母个数为%d 大写字母个数为%d 数字个数为%d ",xiao,da,shu);for(i=0;i<26;i++)fprintf(fp2,"%c=%d ",i+65,all[i]);fclose(fp1);fclose(fp2);}vc++6.0运行成功
2023-07-07 20:50:112

有一首女生唱的英文歌,中间停顿部分是啦啦啦 啦啦啦啦啦啦啦,哼了很长一段,整首歌节奏感很强,求歌名

霹雳英雄布袋戏、不谢
2023-07-07 20:50:1914

编写程序,输入一维数组的10个元素,并将最小值与第1个数交换,最大值与最后一个数交换,然后输出交换后的1

#include<stdio.h>void main(){ int i,max,min,da,xiao,a[10]; printf("请输入任意10个整数 "); for(i=0;i<10;i++) { scanf("%d",&a[i]); } max=a[0]; min=a[0]; for(i=1;i<10;i++) { if(a[i]>max) { max=a[i]; da=i;} if(a[i]<min){ min=a[i]; xiao=i;} } a[da]=a[0]; a[xiao]=a[9]; a[0]=max; a[9]=min; for(i=0;i<10;i++) printf("%d ",a[i]);}
2023-07-07 20:51:032

c++数组复制的函数

#include<iostream>#define max 100using namespace std;class bank{ int top; char date[max][10]; float money[max]; float rest[max]; static float sum;public: bank(){top=0;} void bankin(char d[],float m) { // 数组的名称即可作为指针使用 strcpy(date[top],d); money[top]=m; sum=m+sum; rest[top]=sum; top++; } void bankout(char d[],float m) { strcpy(date[top],d); money[top]=-m; sum=sum-m; rest[top]=sum; top++; } void disp() { int i; printf(" 日期 存入 取出 余额 "); for(i=0;i<top;i++) { printf("%8s ",date[i]); if(money[i]<0) printf("%6f ",-money[i]); else printf("%f ",money[i]); printf("%6d ",rest[i]); } }};float bank::sum=0;void main(){ bank obj; obj.bankin("2002.2.5",1000); obj.bankin("2001.3.2",2000); obj.bankout("2001.4.1",500); obj.bankout("2001.4.5",800); obj.disp();}
2023-07-07 20:51:149

c++程序编写问题2

h> void fun(int a[][34],int n) { int i,j; for(i=0;i<n;i++) for(j=0;j<=i;j++) { if(i==j) a[i][j]=1; else if(j==0) a[i][j]=1; else a[i][j]=a[i-1][j-1]+a[i-1][j]; } } int main() { int i,j,k,n; int a[34][34]; k=1; while(scanf("%d",&n)==1) // 输入你要显示的行数,如1,2,3,4,... { fun(a,n); printf("Case %d: ",k++); for(i=0;i<n;i++) { for (j = 0; j < n - i; j ++) printf(" "); for(j=0;j<=i;j++) { if(j==i) printf("%d",a[i][j]); else printf("%d ",a[i][j]); } printf(" "); } printf(" "); } return 0; }第2个:#include<stdio.h>struct d{ int year; int month; int day;}data;int main(){ int m(struct d da); int n; printf("输入日期:"); scanf("%d%d%d",&data.year,&data.month,&data.day); n=m(data); printf("该日期是%d年第%d天",data.year,n); return 0;}int m(struct d da){ if(da.month==1) return da.day; int i,sum=0,mo[12]=; for(i=0;i<da.month-1;i++) { sum=sum+mo[i]; } sum+=da.day; if(da.year%400==0||da.year%4==0&&da.year%100!=0) if(da.month>2) sum++; return sum;}
2023-07-07 20:51:311

采用表尾插入元素创建一个单链表。

#include<iostream> using namespace std; template <typename T>class List;template <typename T>class Node { friend class List<T>;private: T data; Node<T>* next;public: Node(){data=NULL;next=NULL;} Node(T& da) {data =da;next=NULL;} Node(T& da,Node<T>* ne) {data=da;next = ne};};template <typename T>class List{private: int length; Node<T>* head;//头结点,其next节点为第一个节点 Node<T>* last;//指向最后一个结点的指针public: List(); void insert (T& data); void remove (T data); int getLength() const{return length;}; void print () const; void reverse();};template <typename T>List<T>::List(){ length = 0; head = new Node<T>(); last = head;}template <typename T>void List<T>::insert(T &data){ last = last ->next =new Node<T>(data); length++;}template <typename T>void List<T>::remove(T data){ Node<T>* current = head; while (current->next!=NULL) { if(current->next->data==data) { Node<T>* temp = current->next; current->next = current->next->next; delete temp; length--; } else current = current->next; }}template <typename T>void List<T>::print() const{ Node<T>* current =head; while (current->next!=NULL) { current = current->next; cout<<current->data<<" "; }}template <typename T>void List<T>::reverse(){ Node<T>* temp1;//利用三个临时指针降List中每个结点的next倒向 Node<T>* temp2; Node<T>* temp3; last = head->next; temp1 = head; temp2 = temp1->next; while(temp2!=NULL) { temp3 = temp2->next; temp2->next = temp1; temp1 = temp2; temp2 = temp3; }//倒向完毕 last->next = NULL;//重新设置head和last head->next = temp1;}int main ()//测试代码{ List<int> one; int i1=34,i2=89,i3=232; one.insert(i1); one.insert(i1); one.insert(i1); one.insert(i1); one.insert(i2); one.insert(i3); one.print(); cout<<endl; one.reverse(); one.print(); cout<<endl; one.remove(34); one.print();}我用的是vc2008,应该没问题,都按照要求了
2023-07-07 20:51:393

c语言,一个简单问题,求教

#include <stdio.h>#include <stdlib.h>#include <string.h>struct A{ int a; char b[10]; double c;};struct A f(struct A t);void main(){ struct A a = {1001,"ZhangDa",1098.0}; a = f(a); printf("%d,%s,%6.1f ",a.a,a.b,a.c);}struct A f(struct A t){ t.a=1002; strcpy(t.b,"ChangRong"); t.c=1202.0; return t;}
2023-07-07 20:51:488

C++实现一个Date类 用日/月/年的格式输出日期,设置日期操作;在Date类基础上,实现一个可以进行加天数操作

#include<iostream.h>static int dys[]={31,28,31,30,31,30,31,31,30,31,30,31};class date{ int yr,mo,da;public: date(int y,int m,int d) { yr=y; mo=m; da=d; } date() {} void disp() { cout<<yr<<"年"<<mo<<"月"<<da<<"日"<<endl; } date operator + (int day) { date dt=*this; day+=dt.da; while (day>dys[dt.mo-1]) { day-=dys[dt.mo-1]; dt.mo++; if (dt.mo==13) { dt.mo==1; dt.yr++; } } dt.da=day; return dt; }};void main(){ int y,m,d,a,b; cout<<"输入年月日:"; cin>>y>>m>>d; date d1(y,m,d),d2,d3; d1.disp(); cout<<"输入要加的天数(整数):"; cin>>a; d2=d1+a; d2.disp();}
2023-07-07 20:52:051

The main streets _____ shining in the sun. A.seemed B.are seemed C.are seeming D.has seemed 选哪个

Aseem不用于进行时态和被动语态中
2023-07-07 20:52:123

c语言编程单片机与proteus仿真问题(DA转换)?

双击led,在mode type的属性里调成digital
2023-07-07 20:52:223

#include "stdio.h" main() { int x=8; for(;x>0;x--) { if(x%3) {printf(%d,,x--}

#include <stdio.h>void main() { int x=8; for(;x>0;x--) { if(x%3) { printf("%d ",x--); } }}不知道你说什么意思,帮你完整了下
2023-07-07 20:52:432

在函数中为啥使用结构体指针数组,为其赋值赋不上,(申请了空间),在main函数中可以赋值

你的空间没释放!!free(s);free(root);
2023-07-07 20:53:012

123.有以下程序 #include main() { int a=0,b=0,c=0,d=0; (a++ && b++) ? c++ : d++; printf(

首先,判断(a++&&b++)这个条件,这个条件中又首先判断a++,得到结果为假(由于是后置自增运算符,所以a在判断的时候为0,判断之后为1)。&&运算中,只要有一个条件为假,则整个条件为假,所以程序不再判断b++这个条件,并且将(a++&&b++)这个条件判定为假。所以程序执行冒号后面的d++。所以a=1,b=0,c=0,d=1。所以答案选D
2023-07-07 20:53:101

二级C++考试复习习题集

应付考试,首选谭浩强的书啦~
2023-07-07 20:53:192

c语言问题

若有高手,望详细解答,小弟也很小知道,谢谢
2023-07-07 20:53:293

关于C语言中的while(1)的应用对程序执行的影响

不加while(1)则程序会不停地循环执行整个main()函数,加了的话就会停在while(1)处了。
2023-07-07 20:53:382

C语言编写一万年历系统!高分!

你是沈师软件大一的吧???TC 2.0 /* welcome to use the WanNianLi system! Copyright @ 2005 KongXinCai All rights reserved!:):):)*/ #include<stdio.h> #include<stdlib.h> char* month_str[]={"January","February","March","April","May","June","July","August","September","October","November","December"}; char* week[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; int IsLeapYear(int year) /*find out the year is leap year or not*/ { if((year%4==0&&year%100!=0)||(year%400==0)) return 1; else return 0; } int month_day(int year,int month) { int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31}; if(IsLeapYear(year)&&month==2) return 29; else return(mon_day[month-1]); } int DaySearch(int year,int month,int day) /*search what day this day is*/ { int c=0; float s; int m; for(m=1;m<month;m++) c=c+month_day(year,m); c=c+day; s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c; return ((int)s%7); } int PrintAllYear(int year)/*print the all year*/ { int temp; int i,j; printf(" %d Calander ",year); for(i=1;i<=12;i++) { printf(" %s(%d) ",month_str[i-1],i); printf("0 1 2 3 4 5 6 "); printf("S M T W T F S "); temp=DaySearch(year,i,1); for(j=1;j<=month_day(year,i)+temp;j++) { if(j-temp<=0) printf(" "); else if(j-temp<10) printf("%d ",j-temp); else printf("%d ",j-temp); if(j%7==0) printf(" "); } } return 0; } int main() { int option,da; char ch; int year,month,day; printf("Copyright @ 2005 TianQian All rights reserved!:):):)"); printf(" Welcome to use the WanNianLi system! "); while(1) { printf(" Please select the service you need: "); printf(" 1 Search what day the day is"); printf(" 2 Search whether the year is leap year or not"); printf(" 3 Print the calander of the whole year"); printf(" 4 Exit "); scanf("%d",&option); switch(option) { case 1: while(1) { printf(" Please input the year,month and day(XXXX,XX,XX):"); scanf("%d,%d,%d,%c",&year,&month,&day); da=DaySearch(year,month,day); printf(" %d-%d-%d is %s,do you want to continue?(Y/N)",year,month,day,week[da]); fflush(stdin); scanf("%c",&ch); if(ch=="N"||ch=="n") break; } break; case 2: while(1) { printf(" Please input the year which needs searched?(XXXX)"); scanf("%d",&year); if(IsLeapYear(year)) printf(" %d is Leap year,do you want to continue?(Y/N)",year); else printf(" %d is not Leap year,do you want to continue(Y/N)?",year); fflush(stdin); scanf("%c",&ch); if(ch=="N"||ch=="n") break; } break; case 3: while(1) { printf(" Please input the year which needs printed(XXXX)"); scanf("%d",&year); PrintAllYear(year); printf(" Do you want to continue to print(Y/N)?"); fflush(stdin); scanf("%c",&ch); if(ch=="N"||ch=="n") break; } break; case 4: fflush(stdin); printf("Are you sure?(Y/N)"); scanf("%c",&ch); if(ch=="Y"||ch=="y") exit(0); break; default: printf(" Error:Sorry,there is no this service now! "); break; } } return 0; }
2023-07-07 20:53:481

c语言 求数列中最大值和最小值得差

先排序,再求差
2023-07-07 20:53:585

c语言中函数返回值是指向一维数组的指针的函数怎么写?

typedef double (*point) [2]; point read(int n); 这样如何?
2023-07-07 20:54:163

以下叙述中正确的是a一个c源程序可由一个或多个函数组成b在c程序中注释说明只

以下叙述不正确的是()x0dA:一个C程序可由一个或多个main函数组成x0dB:一个C源程序必须包含一个main函数x0dC:C程序的基本组成单位是函数x0dD:在C程序中,注释说明只能位于一条语句的后面5
2023-07-07 20:54:251

用C语言制作万年历

要DOS下的图形界面的???C++/C#可以不?C太麻烦了 懒得写
2023-07-07 20:54:333

java怎么添加main方法?

public static void main(string[] args){}
2023-07-07 20:54:523

C语言编程 求1 -3 5 -7 9 ....前20项和

#include <stdio.h>#include <stdlib.h>int main(){ int n,sum,i; sum=0; for(i=0; i<20; i++) { n=1+i*2; if(i%2== 1) n=-n; sum+=n; } printf("result:%d",sum); return 0;}
2023-07-07 20:55:023

单片机DA转换产生三角波的c语言程序

你好!你选的那个DA芯片?,是做实物还是仿真就行?
2023-07-07 20:55:111

c语言程序问题

input函数中,需要改为char a[10][80];int i;
2023-07-07 20:55:214

老师出的turbo C语言设计题目。题目如下,跪求大神帮我打下源代码。参考。

现在不动手,将来想做这一行,还是要动手,自己动动手吧,也不难。
2023-07-07 20:55:361

C语言a,b,c三者间比较大小,程序

写一个程序即可。程序详情:#include "stdio.h"main(){int a,b,c;scanf("%d%d%d",&a,&b,&c);if(a>b&&a>c){if(b>c) printf("%d,%d,%d",a,b,c);else printf("%d,%d,%d",a,c,b);}if(b>c&&b>a){if(a>c) printf("%d,%d,%d",b,a,c);else printf("%d,%d,%d",b,c,a);}if(c>a&&c>b){if(a>b) printf("%d,%d,%d",c,a,b);else printf("%d,%d,%d",c,b,a);}getchar();}
2023-07-07 20:55:472

高分求一个汇编语言的完整程序!

已发
2023-07-07 20:56:036

C语言中一个子函数怎么调用另一个子函数的运算?

#include<stdio.h>void fun2(char a1,char a2,char *a3,int b1,int b2,int *b3,float c1,float c2,float *c3){*a3=a1+a2;*b3=b1+b2;*c3=c1+c2;}void fun1(void){char a1=1,a2=2,a3;int b1=100,b2=300,b3;float c1=5.1,c2=6.8,c3;fun2(a1,a2,&a3,b1,b2,&b3,c1,c2,&c3);printf("a3=%d b3=%d c3=%f ",a3,b3,c3);}int main(){fun1();return 0;}
2023-07-07 20:56:181

C语言题目输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数。

#include<stdio.h>int main(){char c;int letters=0,space=0,digit=0,other=0;printf("请输入一段字符 ");while((c=getchar())!=" "){if(c>="a"&&c<="z"||c>="A"&&c<="Z")letters++;else if(c==" ")space++;else if(c>="0"&&c<="9")digit++;elseother++;}printf("字母数:%d 空格数:%d 数字数:%d 其他字符数:%d ",letters,space,digit,other);return 0;}如果没有问题请采纳 谢谢
2023-07-07 20:56:3210

请VB.net高手帮忙看一下这个错误 Fill 参数太多

简单的看了下,你代码写的也太不规范了吧?中西结合啊,你以为中西结合代码就很牛B吗?还是全英文吧。Fill方法有11个重载版本的,但是也不是很复杂,因为我们用的时候也就那么一两个。Fill(DataSet)和Fill(dataset ,tablename)。例如Da.Fill(objDataSet),或者Da.Fill(objDataSet,"Users")。我经常用第二种。你代码中的PasswordTextBox.Text是怎么回事?恕我眼拙!
2023-07-07 20:57:192

mcs 51系列单片机

你这是考试题,还是自己看书吧,书上写的很清楚…
2023-07-07 20:57:491

关于c语言中的类型转换,谢谢了啊!!!

显然是对的嘛!!!
2023-07-07 20:57:572

c++中怎样用枚举类型数据作为二维数组的元素?

#include <stdio.h>enum something{ aa,bb,cc,dd,ee,ff,gg} ;void main(){enum something x[2][3]; int i,j;x[0][0]=dd;x[0][1]=ee;x[0][2]=ff;x[1][0]=aa;x[1][1]=bb;x[1][2]=cc;for (j=0;j<2;j++){for (i=0;i<3;i++) printf("%d ",x[j][i]);printf(" ");}}-------------------------------C++ 头文件换#include<iostream>using namespace std;输出用for (j=0;j<2;j++){for (i=0;i<3;i++) cout << x[j][i] << " ";cout << endl;}
2023-07-07 20:58:114

C语言程序设计题:模拟时钟转动的程序

/*开发环境:turboc2.0模拟时钟转动程序代码*/#include"graphics.h"#include"math.h"#include"dos.h"#definepi3.1415926#defineX(a,b,c)x=a*cos(b*c*pi/180-pi/2)+300#defineY(a,b,c)y=a*sin(b*c*pi/180-pi/2)+240#defined(a,b,c)X(a,b,c);Y(a,b,c);line(300,240,x,y)voidinit()/*划时钟边框函数*/{inti,l,x1,x2,y1,y2;setbkcolor(1);circle(300,240,200);circle(300,240,205);circle(300,240,5);for(i=0;i<60;i++)/*划钟点上的短线*/{if(i%5==0)l=15;elsel=5;x1=200*sin(i*6*pi/180)+300;y1=200*cos(i*6*pi/180)+240;x2=(200-l)*sin(i*6*pi/180)+300;y2=(200-l)*cos(i*6*pi/180)+240;line(x1,y1,x2,y2);}}main(){intx,y,i,k=1;intgdriver=9,gmode=2;unsignedcharh,m,s;into,p,q;floatn;structtimet[1];structdated[1];initgraph(&gdriver,&gmode,"c:\tc");initgraph(&gdriver,&gmode,"c:\tc");for(i=0;i<=6;i++){settextstyle(TRIPLEX_FONT,HORIZ_DIR,i);/*控制输出字符的字体,方向,大小*/cleardevice();settextjustify(1,1);/*在指定坐标上输出字符串*/outtextxy(300,80,"12");outtextxy(300,390,"6");outtextxy(140,230,"9");outtextxy(460,230,"3");outtextxy(380,100,"1");outtextxy(220,100,"11");outtextxy(430,160,"2");outtextxy(430,310,"4");outtextxy(380,370,"5");outtextxy(220,370,"7");outtextxy(160,160,"10");outtextxy(160,310,"8");}init();setwritemode(1);/*设置画线的输出模式*/if(k!=0){getdate(d);/*获得系统日期函数*/o=d[0].da_year;p=d[0].da_mon;q=d[0].da_day;gettime(t);/*获得系统时间函数*/h=t[0].ti_hour;m=t[0].ti_min;s=t[0].ti_sec;}setcolor(7);/*设置时针颜色*/n=(float)h+(float)m/60;d(150,n,30);/*画出时针*/setcolor(14);/*设置分针颜色*/d(170,m,6);/*画出分针*/setcolor(4);/*设置秒针颜色*/d(190,s,6);/*画出秒针*/while(!kbhit())/*控制程序按下任意键退出*/{while(t[0].ti_sec==s)gettime(t);gotoxy(44,18);/*使光标移动到指定坐标*/printf("");/*退格,使表示时间的字符串不断变化*/sound(400);/*按给定的频率打开PC扬声器*/delay(70);/*中断程序的执行,时间为70毫秒*/sound(200);delay(30);nosound();/*按给定的频率关闭PC扬声器*/setcolor(4);d(190,s,6);s=t[0].ti_sec;d(190,s,6);if(t[0].ti_min!=m){setcolor(14);d(170,m,6);m=t[0].ti_min;d(170,m,6);}if(t[0].ti_hour!=h){setcolor(7);d(150,h,30);h=t[0].ti_hour;d(150,h,30);sound(1000);delay(240);nosound();delay(140);sound(2000);delay(240);nosound();}if(s<10)/*用字符的形式输出时间*/{if(m<10)printf("%u:0%u:0%u",h,m,s);elseprintf("%u:%u:0%u",h,m,s);}else{if(m<10)printf("%u:0%u:%u",h,m,s);elseprintf("%u:%u:%u",h,m,s);}gotoxy(34,19);/*在指定坐标上输出日期*/printf("%d年%d月%d日",o,p,q);printf("");}getch();closegraph();}
2023-07-07 20:58:213