阅读 10,11
来源:互联网 发布:门捷列夫 知乎 编辑:程序博客网 时间:2024/06/08 11:46
运行及代码:
#include <iostream>using namespace std;int f(int n);int main(){ cout<<f(5)<<" "; cout<<f(8)<<endl; return 0;}int f(int n){ static int a=2; int b=0; a+=n; b+=a; return b;}
在这里注意
<pre name="code" class="cpp">static int a=2; //在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变量第一次a=2,在第二次 a=7,
运行及代码:
#include <iostream>#include<cstring>using namespace std;void f(char p[][10],int n);int main(){ char p[][10]={"China","America","Russia","England","France"}; f(p,5); cout<<p[0]<<","<<p[4]<<endl; return 0;}void f(char p[][10],int n){ char t[10]; int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(p[i],p[j])<0) { strcpy(t,p[i]); strcpy(p[i],p[j]); strcpy(p[j],t); }}
<img src="http://img.blog.csdn.net/20141207120715671?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2gyMDE0NTg1MDExMDY=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
首先对字符串进行排序,最后输出最大和最小。
0 0
- 阅读 10,11
- 10,11周阅读程序
- 第10、 11 周--阅读程序1
- 10 11周阅读程序(2)
- 10 11周阅读程序(3)
- srilm 阅读文档11
- 11-阅读程序1
- 11-阅读程序2
- srilm 阅读文档10
- 《华为研发》阅读 - 10
- TP0-10-阅读-详解
- 文献阅读(10)
- 阅读
- 阅读
- 阅读
- 阅读
- 阅读
- 阅读
- 2386 Lake counting
- Cocos2d-x常用功能-绘图API:绘制点、线条、圆形、矩形、多边形
- Generate a random password
- 我的素数筛法模板
- 设计模式原则
- 阅读 10,11
- $(document).ready diyici$not defined
- fedora 20 如何在桌面显示图标
- php,js部分语法 cookie session
- hdu 5138 CET-6 test(BestCoder Round #21)
- 专业在线教育平台大批量倒闭,在线教育有无前途
- css hack简介
- conversion to dalvik format failed with ...
- guava中Closer的用法