Update
This commit is contained in:
parent
31f507b004
commit
3ea952c33b
|
@ -0,0 +1,19 @@
|
|||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00s\x00t\x00u\x00d\x00y\x00_\x00c\x00p\x00p)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index-主机系统=0
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=/home/hmtsai/projects/study_cpp/build
|
||||
Build Type=Debug
|
||||
CMake Binary=/usr/bin/cmake
|
||||
CMake Executable=/usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=
|
||||
Runtime=主机系统
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
|
@ -80,7 +80,9 @@ private:
|
|||
|
||||
int main()
|
||||
{
|
||||
Tdate date ( 21,10,2011 );
|
||||
Tdate date ( 31,12,2011 );
|
||||
date.printYear();
|
||||
date.nextDay();
|
||||
date.printYear();
|
||||
cout<<date.isLeapYear() <<endl;
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a[5],i,*pa=a;
|
||||
for(i=0;i<5;i++){
|
||||
scanf("%d",pa);
|
||||
pa++;
|
||||
}
|
||||
pa=a;
|
||||
for(i=0;i<5;i++){
|
||||
printf("a[%d]=%d\n",i,*pa);
|
||||
pa++;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
void swapchar(char &a,char&b){
|
||||
char temp=a;
|
||||
b=a;
|
||||
a=temp;
|
||||
}
|
||||
|
||||
int reverse(char *string_in){
|
||||
int string_len=strlen(string_in);
|
||||
char string_out[string_len];
|
||||
for(int i=0;i<string_len/2;++i){
|
||||
swapchar(string_in[i],string_in[string_len-i-1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(){
|
||||
char string[101];
|
||||
char *in=string;
|
||||
gets(in);
|
||||
reverse(in);
|
||||
cout<<in;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int num,*ptr;
|
||||
cin>>num;
|
||||
ptr = new int[num];
|
||||
for(int i=0;i<num;i++){
|
||||
cin>>ptr[i];
|
||||
}
|
||||
for(int i=1;i<num;i++){
|
||||
ptr[i]+=ptr[i-1];
|
||||
}
|
||||
for(int i=0;i<num;i++){
|
||||
cout<<ptr[i]<<" ";
|
||||
}
|
||||
delete []ptr;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#include <iostream>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
void swap ( int *a,int *b )
|
||||
{
|
||||
int temp=*a;
|
||||
*a=*b;
|
||||
*b=temp;
|
||||
}
|
||||
int sortInt ( int *a,int *b,int *c )
|
||||
{
|
||||
/*
|
||||
int list[4]={ *a,*b,*c };
|
||||
sort ( list+0,list+3 );
|
||||
*a=list[0];
|
||||
*b=list[1];
|
||||
*c=list[2];
|
||||
//这是一个神奇的方法
|
||||
*/
|
||||
if ( a>b ) {
|
||||
swap ( a,b );
|
||||
}
|
||||
if ( a>c ) {
|
||||
swap ( a,c );
|
||||
}
|
||||
if ( b>c ) {
|
||||
swap ( b,c );
|
||||
}
|
||||
//这是一个正常的方法
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int a,b,c,*ptr_a=&a,*ptr_b=&b,*ptr_c=&c;
|
||||
cin>>a>>b>>c;
|
||||
sortInt ( ptr_a,ptr_b,ptr_c );
|
||||
cout<<a<<" "<<b<<" "<<c<<endl;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include <cstdio>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int num;
|
||||
scanf ( "%d",&num );
|
||||
int array[num+1];
|
||||
int *ptr=array+1;
|
||||
for ( int i=1; i<=num; i++ ) {
|
||||
cin>>*ptr;
|
||||
ptr++;
|
||||
}
|
||||
ptr=array+1;
|
||||
for ( int i=1; i<=num; i++ ) {
|
||||
printf ( "%d ",*ptr );
|
||||
ptr++;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
int a=10,*p=&a,**pp=&p;
|
||||
int main(){
|
||||
cout<<"a="<<a<<endl;
|
||||
cout<<"*p="<<*p<<endl;
|
||||
cout<<"**pp="<<**pp<<endl;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a,b,sum,total;
|
||||
cin>>a>>b;
|
||||
int *pointer_a=&a,*pointer_b=&b;
|
||||
sum= ( *pointer_a )+ ( *pointer_b );
|
||||
total= ( *pointer_a ) * ( *pointer_b );
|
||||
cout<<sum<<endl;
|
||||
cout<<total<<endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue