C++字符串求教,求解答,为什么这句可以运行?

大神好,最近开始接触一些C++,在看文献的时候遇到个问题理解不上去。

const char *str = "this is a test\n";
int main() {
    int len = 0;
    while (*str++) {
        len++;

    }

**str = str - len - 1;**
cout << len << ":" << str << endl;

return 0;
}


这句str = str - len -1,这个运算是什么意思啊 、、我用Debug追踪它,运行到这个位置的时候是最后的结束字符啊,为什么可以运算,还能输出整个字符串 求教 谢谢

c++

2个回答

在while循环后,str就已经指向字符串结束符位置了,经过str - len - 1运算,str指针重新指向字符串的首地址,最后输出时为整个字符串

这个是要把字符串的指针重新指向 字符串 的首地址,从而输出整个字符串

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
为什么这句在SQL可以运行,在ACCESS不行?
为什么这句在SQL可以运行,在ACCESS不行?rnupdate temp_kucun rnset temp_kucun.jinhuojia=kucun.jinhuojia,rntemp_kucun.lingshoujia=kucun.lingshoujiarnfrom temp_kucun,kucunrnwhere kucun.shangpinming=temp_kucun.shangpinming AND kucun.id=temp_kucun.idrn上面这个在SQL SERVER可以但ACCESS报错rn------rnrn后来改了种写法才行:rnUPDATE temp_kucun INNER JOIN kucunrn ON (kucun.shangpinming = temp_kucun.shangpinming)rn AND (kucun.id = temp_kucun.id) rnSET temp_kucun.jinhuojia = kucun.jinhuojia,rn temp_kucun.lingshoujia = kucun.lingshoujiarnrn---------------------------rnrn各位老大解析一下其中道理好吗?rn我认真的听,认真的学习!!rn谢谢
高手来 为什么这句也可以运行?
rn c1 = new Mug(1);rn c2 = new Mug(2);rn System.out.println("c1 & c2 initialized");rnrn在上面的代码中为什么 System.out.println("c1 & c2 initialized");也可以运行rn整个代码如下:rnrnclass Mug rn Mug(int marker) rn System.out.println("Mug(" + marker + ")");rn rn void f(int marker) rn System.out.println("f(" + marker + ")");rn rnrnrnpublic class Mugs rnrn Mug c1;rn Mug c2;rn rn c1 = new Mug(1);rn c2 = new Mug(2);rn System.out.println("c1 & c2 initialized");rn rn Mugs() rn System.out.println("Mugs()");rn rn public static void main(String[] args) rn System.out.println("Inside main()");rn Mugs x = new Mugs();rn /*monitor.expect(new String[] rn "Inside main()",rn "Mug(1)",rn "Mug(2)",rn "c1 & c2 initialized",rn "Mugs()"rn );*/rn rn
这句代码啥意思,求解答
[code=C/C++]rnvoid LLWebBrowserCtrl::onNavigateComplete( const EventType& eventIn )rnrn // chain this event on to observers of an instance of LLWebBrowserCtrlrn LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); //这句这个event是怎么回事?rn mEventEmitter.update( &LLWebBrowserCtrlObserver::onNavigateComplete, event ); rnrnrn//其中rnLLWebBrowserCtrlEvent( int intValIn ) :rn mIntVal( intValIn )rn rn ;rnvoid update( observerMethod method, const EventType& msgIn )rn rn typename std::list< T* >::iterator iter = observers.begin();rnrn while( iter != observers.end() )rn rn ( ( *iter )->*method )( msgIn ); //挨个执行observers中的方法,不过这个参数还是很诡异,event?rnrn ++iter;rn ;rn ;rnrn[/code]
求解答这句sql语句
2张表分别为:rnrn数据是rnTableArnrnID Name Money Money777 OperateTimern01 小明 1 10 2011-9-15 13:24:00rn01 小明 3 15 2011-9-15 13:25:00rn01 小明 10 11 2011-9-15 15:19:00rn03 小张 7 8 2011-9-15 15:18:00rn03 小张 8 5 2011-9-13 15:18:00rn07 小王 9 5 2011-9-17 15:18:00rnrnrnrnrnrnTableCrnrnrnPeronID PeronName Money2 Money3 LogTimern01 小明 5 1 2011-9-15 13:24:00rn01 小明 3 3 2011-9-15 13:25:00rn01 小明 2 7 2011-9-15 15:19:00rn03 小张 9 8 2011-9-15 10:19:00rn03 小张 7 2 2011-9-15 15:52:00rn07 小王 null null nullrnrnrnrnrnrnrnrnrnrnselectrn a.id,a.name,a.sum_money1,b.sum_money2,b.sum_money3,c.Money777rnfromrn(rnselect ID,Name,sum(money) as sum_money1rnfrom tableArnwhere OperateTime>'2011-09-14' and OperateTime<'2011-09-21'rngroup by ID,Namern) a left join rn(rnselect PeronID ,PeronName ,sum(money2) as sum_money2,sum(money3) as sum_money3rnfrom tableC rnwhere LogTime>'2011-09-14' and LogTime<'2011-09-21'rngroup by PeronID ,PeronNamern)b rnonrn a.ID=b.PeronID and a.name=b.PeronNamernjoin TableA crnonrn a.ID=c.ID and a.name=c.namernwherern OperateTime =(select MAX( OperateTime ) from TableA where ID=a.ID and OperateTime>'2011-09-14' and OperateTime<'2011-09-21'rn)rnrnrnrn----------------结果----------------------------rn/* id name sum_money1 sum_money2 sum_money3 Money777rn---- ---- ----------- ----------- ----------- -----------rn01 小明 14 10 11 11rn03 小张 7 16 10 8rnrnrnrnrnrnrn假如另外我还想列出小王的信息,数据为空处用缺数据表达,那么这句sql语句该如何写?
新人C语言问题求教求解答
![图片说明](https://img-ask.csdn.net/upload/201610/29/1477711355_975267.png)求解答ABC什么意思
为什么运行不过这句呢?
Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test","sa","626131");rn请各位好心人帮我看看这句有什么问题吗?rn就是这句运行不过rn我实在是没办法了。rn谢谢!!rn
为什么运行不过这句呢??
Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test","sa","626131");rn请各位好心人帮我看看这句有什么问题吗?rn就是这句运行不过rn我实在是没办法了。rn谢谢!!rn
实在不明白为什么运行不了,求解答
[code=java]package com.cl.wx.test;rnrnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.net.HttpURLConnection;rnimport java.net.MalformedURLException;rnimport java.net.URL;rnimport java.util.HashMap;rnimport java.util.List;rnimport java.util.Map;rnrnimport org.dom4j.Document;rnimport org.dom4j.DocumentException;rnimport org.dom4j.Element;rnimport org.dom4j.io.SAXReader;rnrnpublic class WeatherTest rnrn public static void main(String[] args) rn InputStream is = null;rn try rn URL u = new URL(rn "http://php.weather.sina.com.cn/xml.php?city=上海&password=DJOYnieT8234jlsK&day=1");rn HttpURLConnection uConnection = (HttpURLConnection) urn .openConnection();rn uConnection.connect();rn is = uConnection.getInputStream();rn SAXReader reader = new SAXReader();rn Document document = reader.read(is);rn Element root = document.getRootElement();rn Element weather = root.element("Weather");rn List elementList = weather.elements();rn Map map = new HashMap();rn for (Element e : elementList)rn map.put(e.getName(), e.getText());rnrn System.out.println(map.get("city"));rn System.out.println(map.get("gm_s"));rnrn catch (MalformedURLException e) rn e.printStackTrace();rn catch (IOException e) rn e.printStackTrace();rn catch (DocumentException e) rn e.printStackTrace();rn finally rn try rn if (is != null) rn is.close();rn rn catch (IOException e) rn e.printStackTrace();rn rnrn rnrn rnrnrn[/code]rnrn用的dom4j读取XML,我发给同学,在他那里就可以运行 ,在我电脑上就运行不了rn错误如下:rnException in thread "main" java.lang.NullPointerExceptionrn at com.cl.wx.test.WeatherTest.main(WeatherTest.java:32)
字符串截求解答!!
UploadImgs\baidu.jpgrn想取得baidu 请问代码该怎么写!!!
求解答C语言解答!
有一隻公雞往前走了一步,rn又往後走了三步,rn接著又往右走了兩步,rn最後又往左走了一步。 rnrn請問牠在哪裡下蛋呢?rnrn娱乐一下~
2005可以运行,但2000不能运行的语句.求解答..
rncreate procedure x1rnasrndeclare @t table(a1 int)rnrninsert into @t values(1)rninsert into @t values(2)rninsert into @t values(4)rnrnselect a1 from @trnrngornrncreate procedure x2rnasrndeclare @t1 table(a1 int)rndeclare @proce_name varchar(40)rnset @proce_name = 'x1'rnrninsert into @t1 exec @proce_namernrnselect a1 from @t1rngornrn/************/rnexec x2rnrngornrn---------rn2000里说存储过程结果不能作为源插入表变量..但是2005可以..求解 .
为什么这句在access中不能运行,在sqlserver可以?
为什么这句在access中不能运行,在sqlserver可以?我如何改成在access中运行?rnselect a.id,a.sendname,a.recename,a.messagesid,a.isread,a.messagestype,a.title,b.username,b.cname,c.ganwei from wjsms as a left join dwuser as b on a.recename=b.username left join zaopin as c on a.messagesid=c.id where a.ntype='单位用户' and c.ganwei like '%安%'
求c语言大师解答问题,c语言新手求教
求编程语言大师帮我解答疑问。求告知这条代码有什么作用nm<=(int)sqrt(i)这是什么意思![图片](https://img-ask.csdn.net/upload/201611/30/1480508241_444558.jpg)
求解答为什么
运行结果:rn数据库驱动成功rnException in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverterrn at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4098)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3160)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3123)rn at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7505)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2445)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1981)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1628)rn at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1459)rn at com.microsoft.sqlserver.jdbc.SQLSern
为什么 求解答
select t.sqdid,t.jdrq,t.sbmc,t.sqdw,t.xmmc,t.zj,t.dabh,t.xmjbr,t.xmjbrdh,t.sfyx,t1.sgzt,t.sbxh from t_sqd t left outer join t_sqd_da t1 on t.dabh=t1.dabh and t.sglx=t1.sglx where 1=1 and exists(select t2.jfkid from com.cj.pro.domain.t.SqdJfk t2 where t2.sqd.sqdid=t.sqdid and t2.jfkh like '%524005*A61201%') and t.sglx = 1) order by t.createtime descrnrn[color=#FF0000]错误:ORA-00907: 缺失右括号[/color]
C方向求解答
已经学完C得语法了,请大家给点儿建议,因为以后想走C这条路线,不知道学习的顺序是什么,能给点儿具体顺序和相关书籍吗?按C可以走的方向来介绍,谢谢
运行不了呀,求解答!
[code=c][/code]rn#includernusing namespace std;rn#define LinkStack struct linkstackrntypedef int ElemType;rnLinkStackrnrn ElemType data;rn LinkStack *next;rn;rn//链栈的初始化rnLinkStack* InitLinkStack()rnrn LinkStack *top;rn top=new LinkStack;rn top->next='\0';rn cout<<"已初始化一个链栈"<data=x;rn s->next=top;rn top=s;rn return top;rnrn//出栈rnvoid PopLinkStack(LinkStack *top,ElemType *x)rnrn LinkStack *p;rn p=new LinkStack;rnif(top->next=='\0')rn cout<<"ERROR!"<data;rn p=top;rn top=top->next;rn rn rn free(p);rnrn//主函数rn#include"head.h"rnvoid main()rnrnrn LinkStack *top;rn cout<<"初始化一个链栈"<>x;rn top=PushLinkStack(top,x);rn cout<<"出栈"<
运行出现错误,求解答,
代码rn#include rnint main()rnrnrn std::cout<<"五年级一班数学成绩表\n";rn std::cout<<"首先是第一名许凡的成绩:\t"<<100;rn std::cout<
java 字符串 替换,求解答
例如有这样一个字符串字符串:用户[$xx$]的名称[$xx$]原值为[$xx$]。。。n[$xx$]的个数1到5个不定,我需要替换$xx$,有什么方法可以替换指定的第几个$xx$,或者按顺序每次替换下一个$xx$也可以,求方法
字符串为什么可以初始化?
在C++中字符串数组、字符串指针、引号的字符串都是保存起首地址的。rn那么对于字符串数组:rnchar a[5] = "1231";rn是正确的,而rnchar a[5];rna ="1231";不正确?//我明白这里的a的地址已经确定是不能修改的,当然将“1231”的地址赋给a是错误的,但是为什么在初始化的时候可以?rn难道在哪个时候是先确定了“1231”的地址,然后将a指向其地址?还是有其他的意思?rn请给位高手帮忙!rnrn
可以c运行的大数乘法
可以高效快速的实现两个大数相乘,可以C运行
为什么这句sql 可以产生行号
[code=sql]select top 1000rn rn (select count(*) from [weilaixueyuan_db].[dbo].[Jft_Card] b where a.id >= b.id) as ddrn ,* rnfrom [weilaixueyuan_db].[dbo].[Jft_Card] as a [/code]
求教这句sql什么意思。。。
[code=sql]rnrnselect distinct rn a.os_username os_user,rn a.userhost,rn a.username db_user,rn to_char(a.timestamp,'yyyy-mm') Year_Month,rn a.action_name action_name rnfrom dba_audit_trail arnwhere a.timestamp >= to_date(to_char(sysdate,'yyyymm')-1||'16','yyyymmdd') rnand a.timestamp < to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd')rnand a.action in (100)rnorder by a.action_namernrnselect distinct rn a.os_username os_user,rn a.userhost,rn a.username db_user,rn to_char(a.timestamp,'yyyy-mm') Year_Month,rn a.action_name action_name rnfrom dba_audit_trail arnwhere a.timestamp >= to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd') rnand a.timestamp < to_date(to_char(sysdate,'yyyymm')||'16','yyyymmdd')rnand a.action in (100)rnorder by a.action_namern[/code]rn求教这几句话是什么意思???
请问为什么这句可以是非动态的sql
这句为啥可以是非动态的,动态的也可以创建rncreate or replace procedure proc_cursor(dno number,mm out sys_refcursor)rnisrnbeginrn open mm for select * from emp where deptno=dno;rnend;rn----------------------------------------------------------------rn而这句就必须是动态的rn create or replace function fun_emp(tab varchar2)rn return sys_refcursorrn isrn return_cursor sys_refcursor;rn beginrn execute immediate 'open return_cursor for select empno,ename,job,sal from'|| tab;rn return return_cursor;rn end;rn------------------------------------------------------------rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/37.gif][/img]求解rnrnrnrn
求教!!!郁闷!!! 为什么不能运行???
我做了个很小型的系统,考试组件+客户端。rnrn客户端是引入*.dll的*.tlb文件来使用组件的,使用方式为IQuestion m_Question;(IQuestion已经做好了);rnrn组件服务那边我新建了一个应用程序,然后把做的几个DLL组件添加进去。rnrn请分析一下我为什么不能运行程序。rnrn十万火急!
求解答求解答
一般公司招C++程序员是写什么样的程序?windows程序还是什么?rnC++到底能写些什么东西?rn一直说写游戏写游戏,但是我就是不明白怎么写游戏?rnVC++?MFC?API?我怎么感觉这三样都是另外的语言啊???????
c语言字符串处理问题求教!
rnrn一个由‘;’分隔符组成的串,如何把他们依次分开,并将各个子串的指针存储到一个字符指针数组中去,例如:rn源串为1;2;3;4;5;rn要求分割后存储到一个数组中s[0]="1";s[1]="2";s[2]="3"。rn注意,开始并不知道源串中分隔符的个数,要求程序的效率尽可能高,不要采用先用一个循环求出分隔符的个数,然后再用一个循环来依次赋值的方法。 rn rn
求解答,求解答,求解答,谢谢
![图片](https://img-ask.csdn.net/upload/201512/14/1450082237_371680.jpg)
这是为什么呢?求解答!
下面的代码能很好的运行。但是如果将主函数里的while里的输入语句“cin>>s;”改为“scanf("%s",s);” 为什么就不可以呢???(这程序是括号匹配的问题,我用C语言编的。)rnrn#include rn#include rn#include rnusing namespace std;rn#define maxsize 100rnstruct Stackrnrn char sign[maxsize];rn int top;rn;rnint InitStack(Stack *S)rnrn S->top=-1;rn return 1;rnrnint IsEmpty(Stack *S)rnrn if(S->top==-1)return 1;rn return 0;rnrnint PushStack(Stack *S,char c)rnrn S->sign[++S->top]=c;rn return 1;rnrnint Pop(Stack *S)rnrn if(IsEmpty(S))rn rn printf("栈空\n");rn return 0;rn rn S->top--;rn return 1;rnrnchar GetTop(Stack *S)rnrn if(IsEmpty(S))rn rn printf("栈空\n");rn return 0;rn rn return S->sign[S->top];rnrnint main()rnrn char ch;rn printf("进行验证请输入Y,退出请输入N: ");rn scanf("\n%c",&ch);rn while(ch=='Y'|| ch=='y')rn rn string s;rn printf("输入表达式:\n");rn cin>>s;rn int length=s.length();rn int i;rn Stack S;rn InitStack(&S);rn for(i=0;i
求c io高手解答
今天回来遇到一问题,rnrn[code=C/C++]rnrn//1.txt文件大小为1444bytern//windows :rn#include rnrn//linux #include rnrn#include rn/*#include */rnrnint main(void)rnrn// FILE * file = fopen("f:/temp/1.txt", "rb");rn int fd = 0;rn char buff[1024];rn int reads = 0;rn int counts = 0;rn// fd = file->_file;rn fd = _open("f:/temp/1.txt", O_RDONLY, 0777);rnrn while ((reads = _read(fd, buff, sizeof(buff))) > 0) rn counts += reads;rn rnrn reads += 0;rn return 0;rnrn//xp3下vs2008,counts 为1408, ubuntu 12.04下gcc,counts为1444rn[/code]rnrn[code=C/C++][/code]rnrn[code=C/C++]rn// #include rn// #include rn#include rnrnint main(void)rnrn FILE * file = fopen("f:/temp/1.txt", "rb");rn int fd = 0;rn char buff[1024];rn int reads = 0;rn int counts = 0;rn fd = file->_file;rn// fd = _open("f:/temp/1.txt", O_RDONLY, 0777);rnrn while ((reads = _read(fd, buff, sizeof(buff))) > 0) rn counts += reads;rn rnrn reads += 0;rn return 0;rnrn//xp3下vs2008,counts 为1444rn[/code]rnrn真心伤不起,以前只是听说window对c标准支持不够,这回不知道是不是这个问题,请各位各抒己见,谢谢。rn很久不灌水,分不多。全部家当,哈哈。
简单C内联汇编,求解答。。。
main()rnrnrn unsigned int d;rn unsigned int *n=(unsigned int *)0x2000;rn rn asm push csrn asm pop dsrn asm mov ax,0rn asm mov es,axrn asm mov si,offset [color=#FF0000]int9[/color] rn asm mov di,204hrn asm mov cx,offset [color=#FF0000]int9end[/color]-offset [color=#FF0000]int9[/color] rn asm cldrn asm rep movsbrn asm push es:[9*4]rn asm pop es:[200h]rn asm push es:[9*4+2]rn asm pop es:[202h]rn asm clirn asm mov word ptr es:[9*4],204hrn asm mov word ptr es:[9*4+2],0rn asm stirn asm jmp cbeginrnrn[color=#FF0000]int9[/color]:rn asm push axrn asm in al,60hrn asm pushfrn asm call dword ptr cs:[200]rn asm cmp al,10hrn asm jne int9retrn asm mov ax,4c00hrn asm int 21hrnrnint9ret:rn asm pop axrn asm iretrnrn[color=#FF0000]int9end[/color]:rn asm noprnrncbegin:rnrn for( ;n!=(unsigned int *)0;n++)rn rn d=*n;rn printf("%p->%d\n",n,d);rn rnrn printf("\n\n\n");rnrn for(n=(unsigned int *)0x2000;n!=(unsigned int *)0;n++)rn rn d=*n;rn printf("%p->%d\n",(unsigned int *)d,*(unsigned int *)d);rn rnrnrn以上程序为C语言内嵌汇编,汇编部分是为了将新的int9中断例程安装到0:204位置,功能为在运行程序过程中按q键返回DOS。可是在编译时候有两个错误,(1)Undefined symbol: int9 (2)Undefined symbol: int9end。我想问的是这道题怎样才能在汇编语句中获取标号处的偏移地址?
c语言,求大神解答
对于数组参数,我自定义函数形参是一个数,实参是一个数组,是否可以传递?比如int cishu(int x) ..main(int a[][50])
c语言 新手求解答
为什么以下两个程序的运行结果不同...我是为了解决求π的近似值写的两个相同的程序。(两个程序的变量名某些地方不同)rn 代码:(1),rn#includern#includernint main()rnrn int sign=1,y=1;rn double pi=0.0,n=1.0,term=1.0;rn while(fabs(term)>=1e-6)rn rn pi=pi+term;rn n=n+2;rn sign=-sign;rn term=sign/n; rn y++; rn rn rn printf("%d\n",y);rn pi=pi*4;rn printf("%10.8f\n",pi);rn return 0;rnrn rn(2),rn#includern #includern int main ()rn rn int i=1;rn float x=1.0,y,pi=0.0,j=0.0;rn for(y=1;;y++)rn rn j=i/x;rn if(fabs(j)<1e-6)break;rn pi=pi+j;rn x=x+2;rn i=-i; rn rn printf("%.0f\n",y);rn pi=pi*4;rn printf("%10.8f\n",pi);rn return 0;rn
C语言新手求解答
[size=18px]数值1101.101可表示成M=1101.101=0.1101101*2^4rn为什么二进制表示为M=0.1101101*2^100rn这个100是怎么回事,求大神解答!!!!!!!!!1[
c return 出错。求解答
感觉是不是我眼龊了哪里没看清楚,mid最后一次的值时2,然后return mid,result得到的却是1,为什么?rn```rn#includernrnint binary_Search(int a[],int low,int high,int key)rn if(low>high) return -1;rn elsern int mid=low+(high-low)/2;rn printf("low=%d,mid=%d,high=%d\n",low,mid,high);rn if(a[mid]==key) rn printf("a[mid]=%d,mid=%d\n",a[mid],mid);rn return mid;rn rn if(a[mid]key)rn binary_Search(a,low,mid-1,key);rn rnrnrnrnint main()rn int a[]=0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16;rn int result;rn result=binary_Search(a,0,16,2);rn printf("result=%d\n",result);rn return 0;rnrn```rnrnrn![图片说明](https://img-ask.csdn.net/upload/201602/23/1456217607_395491.png)
为什么输入数据后,没办法运行,求大神解答。
#include "stdio.h"rnvoid main()rnrn float PI, r,h,s1,s2,s3,v1,v2;rn PI=3.14;rn printf("请输入r和h的值:");rn scanf("%f%f",&r,&h); //输入r和h的值rn s1=2*r*PI; //圆周长rn s2=PI*r*r; //圆面积rn s3=4*PI*r*r; //圆球表面积rn v1=4.0/3.0*PI*r*r*r; //圆球体积rn v2=PI*r*r*h; //圆柱体积rn printf("s1=%6.2f\n",s1);rn printf("s2=%6.2f\n",s2);rn printf("s3=%6.2f\n",s3);rn printf("v1=%6.2f\n",v1);rn printf("v2=%6.2f\n",v2);rn
求解答(C语言入门者)
# include rnrn void main () uigned int a=30;rn int b=-130,c ;rnrn c=(a+b) / 2;rn printf("c=%d\n", c);rn 运行结果为c=2147483598 (vc下)rn c=32718(BC下)rnrnrnrn # include
,,,,,C语言填空题求解答
![图片说明](https://img-ask.csdn.net/upload/201611/02/1478056680_238346.png)n分析
c语言题目求解答~~~~~
自然数列1,2,3,4,5,......大家都很熟悉,现将自然数列写成一排,数字中间不留空格等任何分隔符号就成了如下这样n123456789101112131415161718192021......n这是一个很长很长的串,现要求在这个串中找到一个最先出现给定子串的位置。例如给定子串1112,这该子串最先出现在串中第12个字符位置n为了能简化处理,我们保证评判时给定的子串在串中一定出现,且位置不大于10000.nn输入格式nn给定的子串(一行由数字字符构成的字符串,不超过80个字符),请使用scanf("%s",........)读取n输出格式nn最先出现子串的位置n输入样例nn1112n输出样例nn12
C和C++的文件读写求解答
怎样用C或C++代码来实现文件的读取和写,特别是从文件中读取信息,怎样实现从文件中读取特定的内容,还有就是文件的更新,怎样对文件的内容实现删除和添加操作??求帮忙,谢谢了
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件