Calendar
« June 2011 » |
Su |
Mo |
Tu |
We |
Th |
Fr |
Sa |
| | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Statistics
Total online: 1 Guests: 1 Users: 0
|
Main » 2011 » June » 10
#include <iostream>
using namespace std;
int main() { int i,j,n; cin>>n; for(int i=n;i>0;--i) { for(int j=i;j>0;j--) cout<<'*'; cout<<endl;}
return 0; }
|
#include <iostream>
using namespace std;
int main() { for(int n=9, i=0; n>0, i<10; n--, i++){ cout<<n<<", "; cout<<i<<", "; } cout<<"Fire!"<<endl; return 0; }
|
#include <iostream> #include <string> #include <sstream>
using namespace std;
int main() { int value1, value2, m; string b="Enter a number: "; string a; cout<<b; getline(cin,a); stringstream(a)>>value1; cout<<b; getline(cin,a); stringstream(a)>>value2; m=value1*value2; if (m>50) cout<<"m > 50 and is equal to "<<m; else if (m<50) cout<<"m < 50 and is equal to "<<m; else cout<<"m = 50";cin.get(); return 0; }
|
#include <iostream>
using namespace std;
int main() { long a; do{ cout<<"Enter Number (0 to end): "; cin>>a; cout<<"You Entered: "<<a<<endl; }while(a>0); return 0; }
|
#include <iostream > using std :: cout; using std :: endl; void encrypt( char [ ] ); // prototypes of functions used in the code void decrypt( char * ePtr ); int main( ) { // create a string to encrypt char string[ ] = "this is a secret!"; cout << "Original string is: " << string << endl; encrypt( string ); // call to the function encrypt( ) cout << "Encrypted string is: " << string << endl; decrypt( string ); // call to the function decrypt( ) cout << "Decrypted string is: " << string << endl; return 0; }// main
//encrypt data void encrypt (char e[] ) { for( int i=0; e[i] != '\0'; ++i ) ++e[i]; } // encrypt
//decrypt data void decrypt( char * ePtr ) { for( ; * ePtr != '\0'; ++ ePtr ) --(* ePtr); }
|
#include <iostream> #include <cstdlib> using namespace std; long long Exp(long long base, long long exp) { long long r=base; for(int i=1;i<exp;i++) r*=base; return r; } int main() { long long A,B; long long base,mod; for(;;) { cout << "Base: " << endl; cin >>base; cout << "Modulus: " << endl; cin >>mod; cout << "Alice, choose your secret number: " << endl; cin >>A; cout << "Bob, choose your secret number: " << endl; cin >>B; long long a=Exp(base,A)%mod; long long b=Exp(base,B)%mod; cout << "Alice's value: " << a << endl; cout << "Bob's value: " << b << endl; long long akey=Exp(b,A)%mod; long long bkey=Exp(a,B)%mod; cout << "Alice's key: " << akey << endl; cout << "Bob's key: " << bkey << endl; } system("PAUSE"); return EX
...
Read more »
|
#include <iostream> using namespace std; #define arg dbl a,dbl b,dbl c #define dbl double dbl max1(arg){ a=(a>b ? (a>c ? a:c) : (b>c ? b : c)); return a; } dbl min1(arg){ a=(a<b ? (a<c ? a : c) :(b<c ? b : c)); return a; } dbl sum1(arg){ return a+b+c; } dbl average1(arg){ return (a+b+c)/3; } int main(){ dbl x,y,z,m,s,d,e; cout<<"please enter the first value"<<endl; cin>>x; cout<<"please enter the second value"<<endl; cin>>y; cout<<"please enter the third value"<<endl; cin>>z; s=sum1(x,y,z); m=average1(x,y,z); &nbs
...
Read more »
|
//Note, this works only by GCC compiler #include <iostream> #include <fstream> using namespace std; #define r m int bazm(int x,int y){ return (x*y); } int main() { cout<<"Enter the quantity of numbers"<<endl; int m; cin>>m; ofstream out("out.txt"); int i, j; int a[r][r]; for (i=0;i<r;i++){ for (j=0;j<r;j++) a[i][j]=bazm(i,j); } for (i=0;i<r;i++){ out<<endl; for (j=0;j<r;j++) out<<i<<" * "<<j<<" = "<<a[i][j]<<endl; } &n
...
Read more »
|
#include <iostream>
using namespace std;
int main() { int n, tiv; cin>>n; if(n>=1){ if(n<=9){ for(tiv=1;tiv<=n;tiv++){ cout<<n; }}} return 0; }
|
#include <iostream>
using namespace std;
int main() { char a; cin>>a; a|=(1<<5); cout<<a<<endl; cin.get(); return 0; }
|
#include <iostream>
using namespace std;
int main() { char a; cin>>a; a^=(1<<5); cout<<a; cin.get(); return 0; }
|
#include <iostream> using namespace std; int main() { int num; for(;;){ cin>>num; do { cout<<num%10; num/=10; } while(num>0); cout<<endl<<"\n"; } return 0; }
|
#include <iostream>
using namespace std;
int modInverse(int a, int n) { int i = n, v = 0, d = 1; while (a>0) { int t = i/a, x = a; a = i % x; i = x; x = d; d = v - t*x; v = x; } v %= n; if (v<0) v = (v+n)%n; return v; }
int main() { cout << modInverse(8,16); return 0; }
|
#include <iostream>
using namespace std;
int shrjum(int tiv) { int n=1, t = tiv; while ((t/10)!=0) { t/=10; n *=10; } if (tiv>=10) return (n*(tiv%10)) + shrjum(tiv/10); else return (tiv%10); }
int main(){ int x; cin>>x; cout<<shrjum(x); return 0; }
|
#include <iostream>
using namespace std;
int main() { int x,a(0); cin>>x; do{ a*=10; a+=x%10; x/=10; }while(x>0); cout<<a; return 0; }
|
#include <iostream>
using namespace std;
int main() { int a,b; cin>>a>>b; a+=b; b=a-b; a-=b; cout<<endl<<a<<endl<<b; return 0; }
|
#include <iostream>
using namespace std;
int main() { int a,b; cin>>a>>b; a^=b; b=a^b; a^=b; cout<<endl<<a<<endl<<b<<endl; return 0; }
|
#include <iostream>
using namespace std;
int main() { int a,b,c,d; cout <<"enter a,b,c,d"<<endl; cin >>a>>b>>c>>d; cout <<(a>b?(a>c?(a>d?a:d):(c>d?c:d)):(b>c?(b>d?b:d):(c>d?c:d)));
return 0; }
| |
|