Nomor 1
input c++:
#include <iostream>
#include <string.h>
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
string a,b;int c;
cout<<"Kalimat Pertama : ";
getline(cin, a);
cout<<"Kalimat Kedua : ";
cin>>b;
cout<<a<<endl;
cout<<"Menyisipkan kata pada karakter ke : ";cin>>c;
a.insert(c, b+" ");
cout<<a;
return 0;
}
output c++:
nomor 2
input c++:
#include <iostream>
#include <string.h>
#include <conio.h>
using namespace std;
int main()
{
int i,jum;
char string[100];
cout<<"Masukkan sembarang kalimat :\n";
cin.getline(string,100);
if((string[0]>='a')&& (string[0]<='z'))
string[0]=(char)string[0]-32;
jum=1;int d=0;
for(i=0;i<(int)strlen(string);i++)
{ if(i%2==0){
if((string[jum]>='A')&& (string[jum]<='Z'))
string[jum]=(char)string[jum]+32;
jum++;}
}
for(i=1;string[i]!='\0';i++)
{
if(string[i]==' ') d++;
if((i-1-d)%2==0)
{
if(string[i+1]>='a' && string[i+1]<='z')
string[i+1]=(char)(string[i+1]-32);
}
}
cout<<"Hasil Akhir : "<<string<<endl;
getch();
}
output c++:
nomor 3
input c++:
#include<stdio.h>
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
char kalimat[100];
int i, spasi=0;
cout << "\n\t\t - Program Menghitung Kata Dalam Sebuah Kalimat -\n";
cout << "\t==================================================================\n\n";
cout << "\t Masukan Sebuah Kalimat : ";
cin.getline(kalimat, sizeof(kalimat));
for(i=0; kalimat[i]; i++)
{
if(isspace (kalimat[i]) || ispunct (kalimat[i]))
{
spasi++;
}
}
cout << "\t Jumlah Kata = " << spasi +1 << "\n\n";
cout << "\t Kata yang anda masukan adalah : \n";
cout << "\t ";
for(i=0; kalimat[i]; i++)
{
if(isspace (kalimat[i]) || ispunct (kalimat[i]))
{
spasi++;
cout << "\n";
cout << "\t";
}
cout << kalimat[i];
}
cout << "\n";
cout << "\t==================================================================\n\n";
cout << "\n";
getchar();
}
output:
nomor 4
input c++:
#include <iostream>
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class Vektor {
friend ostream& operator<<(ostream&, Vektor&);
friend istream& operator>>(istream&, Vektor&);
friend class SPL;
public:
Vektor();
void penjumlahan_vektor(const Vektor& A, const Vektor& B);
void perkalian_vektor(float k, const Vektor& A);
void beri_nilaiBanyak(int);
private:
int elemen[100];
int banyak; };
int main(int argc, char** argv) {
return 0;
}
#include <cstdlib>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class Vektor {
friend ostream& operator<<(ostream&, Vektor&);
friend istream& operator>>(istream&, Vektor&);
friend class SPL;
public:
Vektor();
void penjumlahan_vektor(const Vektor& A, const Vektor& B);
void perkalian_vektor(float k, const Vektor& A);
void beri_nilaiBanyak(int);
private:
int elemen[100];
int banyak; };
int main(int argc, char** argv) {
return 0;
}
output c++:
wassalamualaikum w.w.http://al-likenet.blogspot.co.id/
http://dwiharlina.blogspot.co.id/
0 komentar:
Posting Komentar