#include <iostream>
#include <fstream>
using namespace std;
int main ( )
{
char input;
cin. get ( input) ;
while ( cin. get ( input) && input != '@' )
{
if ( ! isdigit ( input) )
{
if ( isupper ( input) )
{
input = input + 32 ;
}
else if ( islower ( input) )
{
input = input - 32 ;
}
cout << input;
}
}
return 0 ;
}
#include <iostream>
#include <fstream>
using namespace std;
int main ( )
{
double donation[ 10 ] ;
cout << "Please input donation\n" ;
int i = 0 ;
double average = 0 ;
int conut = 0 ;
while ( i< 10 && cin>> donation[ i] )
{
average + = donation[ i] ;
i++ ;
}
cout<< "Done : wrong or i>10\n" ;
average = average/ i;
for ( int j = 0 ; j < 10 ; j++ )
{
if ( donation[ j] > average)
conut++ ;
}
cout<< "AVERAGE: " << average<< " conut:" << conut<< endl;
return 0 ;
}
#include <iostream>
#include <fstream>
using namespace std;
int main ( )
{
char input;
cout<< "Please enter one of the following choices:\n" ;
cout<< "c) carnibore\t p) pianist\nt) tree\t g) game\n" ;
while ( cin. get ( input) )
{
switch ( input)
{
case 'c' :
cout<< "A maple is a carnivore\n" ;
break ;
case 'p' :
cout<< "A maple is a pianist\n" ;
break ;
case 't' :
cout<< "A maple is a tree\n" ;
break ;
case 'g' :
cout<< "A maple is a game\n" ;
break ;
default :
cout<< "Please enter c,p,t,g:" ;
cin. get ( ) ;
break ;
}
if ( input == 'c' || input == 'p' || input == 't' || input == 'g' )
break ;
}
return 0 ;
}
#include <iostream>
#include <fstream>
using namespace std;
const int strsize = 20 ;
const int people = 5 ;
struct BOP
{
char fullname[ strsize] ;
char title[ strsize] ;
char bopname[ strsize] ;
int preference;
} ;
int main ( )
{
char choice;
BOP * bop = new BOP [ people] ;
for ( int i= 0 ; i < people; i++ )
{
cout<< "NUM:" << i+ 1 << endl;
cout << "Please input fullname:" ;
cin. getline ( ( bop + i) - > fullname, strsize) ;
cout << "Please input title:" ;
cin. getline ( ( bop + i) - > title, strsize) ;
cout << "Please input bopname:" ;
cin. getline ( ( bop + i) - > bopname, strsize) ;
cout << "Please input preference:" ;
cin>> ( bop+ i) - > preference;
cin. get ( ) ;
}
cout << "Enter your choice:" ;
while ( cin. get ( choice) && choice!= 'q' )
{
cin. get ( ) ;
switch ( choice)
{
case 'a' :
for ( int i = 0 ; i< people; i++ )
cout<< ( bop + i) - > fullname<< endl;
break ;
case 'b' :
for ( int i = 0 ; i< people; i++ )
cout<< ( bop + i) - > title<< endl;
break ;
case 'c' :
for ( int i = 0 ; i< people; i++ )
cout<< ( bop + i) - > bopname<< endl;
break ;
case 'd' :
for ( int i = 0 ; i< people; i++ )
{
switch ( ( bop + i) - > preference)
{
case 0 :
cout<< ( bop + i) - > fullname<< endl;
break ;
case 1 :
cout<< ( bop + i) - > title<< endl;
break ;
case 2 :
cout<< ( bop + i) - > bopname<< endl;
break ;
default :
break ;
}
}
break ;
default :
cout<< "input choices error!!" << endl;
break ;
}
cout<< "Next Choice:" ;
}
cout << "Bye!\n" ;
delete [ ] bop;
return 0 ;
}
#include <iostream>
using namespace std;
int main ( )
{
double tax, salary = 0.0 ;
cout << "Please input salary:\n" ;
while ( cin>> salary && salary>= 0 )
{
while ( salary> 0 )
{
if ( salary> 35000 )
{ tax + = ( salary- 35000 ) * 0.2 ;
salary = 35000 ;
}
else if ( salary> 15000 )
{
tax + = ( salary - 15000 ) * 0.15 ;
salary = 15000 ;
}
else if ( salary> 5000 )
{
tax + = ( salary - 5000 ) * 0.1 ;
salary = 5000 ;
}
else
{
salary = 0 ;
}
}
cout<< "tax:" << tax<< endl;
tax = 0 ;
}
return 0 ;
}
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
struct DONATE
{
string name;
double money;
} ;
int main ( )
{
int num = 0 ;
int conut = 0 ;
string a;
cout<< "Please input num:" ;
cin>> num;
cin. get ( ) ;
DONATE * donate = new DONATE[ num] ;
for ( int i = 0 ; i < num; i++ )
{
cout<< "NUM:" << i+ 1 << endl;
cout<< "name: " ;
getline ( cin, ( donate+ i) - > name) ;
cout<< "money: " ;
cin>> ( donate+ i) - > money;
cin. get ( ) ;
}
cout<< "Grand Patrons:\nname\tmoner\n" ;
for ( int i = 0 ; i< num; i++ )
{
if ( ( donate+ i) - > money > 10000 )
{
cout<< ( donate+ i) - > name<< "\t" << ( donate+ i) - > money<< endl;
conut++ ;
}
}
if ( ! conut)
{
cout<< "None\n" ;
}
conut = 0 ;
cout<< "Patrons:\nname\tmoner\n" ;
for ( int i = 0 ; i< num; i++ )
{
if ( ( donate+ i) - > money <= 10000 )
{
cout<< ( donate+ i) - > name<< "\t" << ( donate+ i) - > money;
conut++ ;
}
}
if ( ! conut)
{
cout<< "None\n" ;
}
delete [ ] donate;
return 0 ;
}
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main ( )
{
string word;
int num_a= 0 ;
int num_b= 0 ;
int num_c = 0 ;
cout << "Enter words (q to quit):" << endl;
while ( cin>> word&& word != "q" )
{
cout << word << endl;
if ( isalpha ( word[ 0 ] ) )
{
if ( word[ 0 ] == 'A' || word[ 0 ] == 'E' || word[ 0 ] == 'I' || word[ 0 ] == 'O' || word[ 0 ] == 'U' ||
word[ 0 ] == 'a' || word[ 0 ] == 'e' || word[ 0 ] == 'i' || word[ 0 ] == 'o' || word[ 0 ] == 'u' )
num_a++ ;
else
num_b++ ;
}
else
num_c++ ;
}
cout << "vowels:" << num_a<< " consonants:" << num_b<< " others:" << num_c<< endl;
return 0 ;
}
#include <iostream>
#include <cstring>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
int main ( )
{
ifstream inFile;
int count = 0 ;
inFile. open ( "scores.txt" ) ;
char word;
inFile. get ( word) ;
while ( inFile. good ( ) )
{
++ count;
inFile. get ( word) ;
}
cout << "count:" << count<< endl;
return 0 ;
}
#include <iostream>
#include <cstring>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
struct DONATE
{
string name;
double money;
} ;
int main ( )
{
ifstream inFile;
inFile. open ( "scores.txt" ) ;
if ( ! inFile. is_open ( ) )
{
cout << "Could not open the file" ;
exit ( EXIT_FAILURE) ;
}
int num = 0 ;
int conut = 0 ;
inFile >> num;
inFile. get ( ) ;
DONATE * donate = new DONATE[ num] ;
for ( int i = 0 ; i < num; i++ )
{
getline ( inFile, ( donate+ i) - > name) ;
inFile>> ( donate+ i) - > money;
inFile. get ( ) ;
}
cout<< "Grand Patrons:\nname\tmoner\n" ;
for ( int i = 0 ; i< num; i++ )
{
if ( ( donate+ i) - > money > 10000 )
{
cout<< ( donate+ i) - > name<< "\t" << ( donate+ i) - > money<< endl;
conut++ ;
}
}
if ( ! conut)
{
cout<< "None\n" ;
}
conut = 0 ;
cout<< "Patrons:\nname\tmoner\n" ;
for ( int i = 0 ; i< num; i++ )
{
if ( ( donate+ i) - > money <= 10000 )
{
cout<< ( donate+ i) - > name<< "\t" << ( donate+ i) - > money<< endl;
conut++ ;
}
}
if ( ! conut)
{
cout<< "None\n" ;
}
delete [ ] donate;
return 0 ;
}